"use strict";var _n=Object.create;var Mt=Object.defineProperty;var nn=Object.getOwnPropertyDescriptor;var on=Object.getOwnPropertyNames;var En=Object.getPrototypeOf,an=Object.prototype.hasOwnProperty;var er=(E,e)=>{for(var s in e)Mt(E,s,{get:e[s],enumerable:!0})},tr=(E,e,s,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of on(e))!an.call(E,n)&&n!==s&&Mt(E,n,{get:()=>e[n],enumerable:!(t=nn(e,n))||t.enumerable});return E};var m=(E,e,s)=>(s=E!=null?_n(En(E)):{},tr(e||!E||!E.__esModule?Mt(s,"default",{value:E,enumerable:!0}):s,E)),An=E=>tr(Mt({},"__esModule",{value:!0}),E);var eE={};er(eE,{SqlError:()=>L,createConnection:()=>en,createPool:()=>tn,createPoolCluster:()=>sn,default:()=>zo,defaultOptions:()=>z_,importFile:()=>rn,version:()=>J_});module.exports=An(eE);var Be={name:"mariadb",version:"3.5.3",description:"fast mariadb or mysql connector.",type:"module",exports:{".":{import:{types:"./types/index.d.ts",default:"./promise.js"},require:{types:"./types/index.d.cts",default:"./dist/promise.cjs"}},"./callback":{import:{types:"./types/callback.d.ts",default:"./callback.js"},require:{types:"./types/callback.d.cts",default:"./dist/callback.cjs"}}},types:"types/index.d.ts",directories:{lib:"lib",test:"test"},private:!1,scripts:{build:"npm run build:cjs","build:cjs":"esbuild promise.js --bundle --minify --platform=node --format=cjs --target=node20 --external:denque --external:iconv-lite --external:lru-cache --outfile=dist/promise.cjs && esbuild callback.js --bundle --minify --platform=node --format=cjs --target=node20 --external:denque --external:iconv-lite --external:lru-cache --outfile=dist/callback.cjs",test:"npm run test:types-prettier && npm run test:prettier && npm run test:tsc && npm run test:types && npm run test:lint && npm run test:imports && npm run test:base","test:base":"vitest --no-file-parallelism --isolate --reporter=verbose run","test:imports":"npm run build && node test/import/cjs.cjs && node test/import/esm.mjs && npm run test:imports:tsc","test:imports:tsc":"tsc --noEmit -p test/import/tsc/cjs-node16.tsconfig.json && tsc --noEmit -p test/import/tsc/esm-nodenext.tsconfig.json && tsc --noEmit -p test/import/tsc/bundler.tsconfig.json","test:lint":'eslint "*.js" "{tools,lib,test,benchmarks}/**/*.js"',"test:tsc":"tsc --noEmit -p types/tsconfig.json","test:types":'eslint "types/*.ts"',"test:types-prettier":'prettier --write "types/*.ts"',"test:prettier":'prettier --write "*.js" "{tools,lib,test,benchmarks}/**/*.js"',prepublishOnly:"npm run build",coverage:"npm run coverage:test && npm run coverage:create && npm run coverage:send","coverage:test":"nyc vitest --no-file-parallelism --isolate --reporter=verbose run","coverage:report":"npm run coverage:create && npm run coverage:send","coverage:create":"nyc report --reporter=text-lcov > coverage.lcov","coverage:send":"./codecov --disable=gcov",benchmark:"node benchmarks/benchmarks-all.js","benchmark:setup":"npm install --no-save promise-mysql mysql2",generate:"node tools/generate-mariadb.js"},repository:{type:"git",url:"git+https://github.com/mariadb-corporation/mariadb-connector-nodejs.git"},keywords:["mariadb","mysql","client","driver","connector"],files:["lib","types/index.d.ts","types/callback.d.ts","types/share.d.ts","types/index.d.cts","types/callback.d.cts","types/share.d.cts","promise.js","check-node.js","callback.js","dist/"],engines:{node:">= 20.0.0"},author:"Diego Dupin ",license:"LGPL-2.1-or-later",dependencies:{"@types/geojson":"^7946.0.16","@types/node":">=20",denque:"^2.1.0","iconv-lite":"^0.7.2","lru-cache":"^11.5.0"},devDependencies:{"@typescript-eslint/eslint-plugin":"^8.59.0","@typescript-eslint/parser":"^8.59.0",chalk:"^5.6.0","error-stack-parser":"^2.1.4",esbuild:"^0.28.0",eslint:"^10.4.0","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.5",nyc:"^18.0.0",prettier:"^3.8.0",tinybench:"^6.0.2",typescript:"^5.9.3",vitest:"^4.1.0",winston:"^3.19.0"},bugs:{url:"https://jira.mariadb.org/projects/CONJS/"},homepage:"https://github.com/mariadb-corporation/mariadb-connector-nodejs#readme"};function hn(E,e){let s=E.split("."),t=e.split("."),n=Number(s[0]),o=Number(t[0]);if(n>o)return!0;if(n=A}var cn=Be.engines.node,sr=cn.replace(">=","").trim(),ln=process.version.replace("v","");hn(ln,sr)||(console.error(`please upgrade node: mariadb requires at least version ${sr}`),process.exit(1));var L={};er(L,{client:()=>N,createError:()=>f,createFatalError:()=>w,default:()=>ve,getClientErrorKey:()=>rr});var i={};i[120]="HA_ERR_KEY_NOT_FOUND";i[121]="HA_ERR_FOUND_DUPP_KEY";i[122]="HA_ERR_INTERNAL_ERROR";i[123]="HA_ERR_RECORD_CHANGED";i[124]="HA_ERR_WRONG_INDEX";i[126]="HA_ERR_CRASHED";i[127]="HA_ERR_WRONG_IN_RECORD";i[128]="HA_ERR_OUT_OF_MEM";i[129]="HA_ERR_RETRY_INIT";i[130]="HA_ERR_NOT_A_TABLE";i[131]="HA_ERR_WRONG_COMMAND";i[132]="HA_ERR_OLD_FILE";i[133]="HA_ERR_NO_ACTIVE_RECORD";i[134]="HA_ERR_RECORD_DELETED";i[135]="HA_ERR_RECORD_FILE_FULL";i[136]="HA_ERR_INDEX_FILE_FULL";i[137]="HA_ERR_END_OF_FILE";i[138]="HA_ERR_UNSUPPORTED";i[139]="HA_ERR_TO_BIG_ROW";i[140]="HA_WRONG_CREATE_OPTION";i[141]="HA_ERR_FOUND_DUPP_UNIQUE";i[142]="HA_ERR_UNKNOWN_CHARSET";i[143]="HA_ERR_WRONG_MRG_TABLE_DEF";i[144]="HA_ERR_CRASHED_ON_REPAIR";i[145]="HA_ERR_CRASHED_ON_USAGE";i[146]="HA_ERR_LOCK_WAIT_TIMEOUT";i[147]="HA_ERR_LOCK_TABLE_FULL";i[148]="HA_ERR_READ_ONLY_TRANSACTION";i[149]="HA_ERR_LOCK_DEADLOCK";i[150]="HA_ERR_CANNOT_ADD_FOREIGN";i[151]="HA_ERR_NO_REFERENCED_ROW";i[152]="HA_ERR_ROW_IS_REFERENCED";i[153]="HA_ERR_NO_SAVEPOINT";i[154]="HA_ERR_NON_UNIQUE_BLOCK_SIZE";i[155]="HA_ERR_NO_SUCH_TABLE";i[156]="HA_ERR_TABLE_EXIST";i[157]="HA_ERR_NO_CONNECTION";i[158]="HA_ERR_NULL_IN_SPATIAL";i[159]="HA_ERR_TABLE_DEF_CHANGED";i[160]="HA_ERR_NO_PARTITION_FOUND";i[161]="HA_ERR_RBR_LOGGING_FAILED";i[162]="HA_ERR_DROP_INDEX_FK";i[163]="HA_ERR_FOREIGN_DUPLICATE_KEY";i[164]="HA_ERR_TABLE_NEEDS_UPGRADE";i[165]="HA_ERR_TABLE_READONLY";i[166]="HA_ERR_AUTOINC_READ_FAILED";i[167]="HA_ERR_AUTOINC_ERANGE";i[168]="HA_ERR_GENERIC";i[169]="HA_ERR_RECORD_IS_THE_SAME";i[170]="HA_ERR_LOGGING_IMPOSSIBLE";i[171]="HA_ERR_CORRUPT_EVENT";i[172]="HA_ERR_NEW_FILE";i[173]="HA_ERR_ROWS_EVENT_APPLY";i[174]="HA_ERR_INITIALIZATION";i[175]="HA_ERR_FILE_TOO_SHORT";i[176]="HA_ERR_WRONG_CRC";i[177]="HA_ERR_TOO_MANY_CONCURRENT_TRXS";i[178]="HA_ERR_NOT_IN_LOCK_PARTITIONS";i[179]="HA_ERR_INDEX_COL_TOO_LONG";i[180]="HA_ERR_INDEX_CORRUPT";i[181]="HA_ERR_UNDO_REC_TOO_BIG";i[182]="HA_FTS_INVALID_DOCID";i[184]="HA_ERR_TABLESPACE_EXISTS";i[185]="HA_ERR_TOO_MANY_FIELDS";i[186]="HA_ERR_ROW_IN_WRONG_PARTITION";i[187]="HA_ERR_ROW_NOT_VISIBLE";i[188]="HA_ERR_ABORTED_BY_USER";i[189]="HA_ERR_DISK_FULL";i[190]="HA_ERR_INCOMPATIBLE_DEFINITION";i[191]="HA_ERR_FTS_TOO_MANY_WORDS_IN_PHRASE";i[192]="HA_ERR_DECRYPTION_FAILED";i[193]="HA_ERR_FK_DEPTH_EXCEEDED";i[194]="HA_ERR_TABLESPACE_MISSING";i[195]="HA_ERR_SEQUENCE_INVALID_DATA";i[196]="HA_ERR_SEQUENCE_RUN_OUT";i[197]="HA_ERR_COMMIT_ERROR";i[198]="HA_ERR_PARTITION_LIST";i[199]="HA_ERR_NO_ENCRYPTION";i[200]="HA_ERR_ROLLBACK";i[201]="HA_ERR_LOCAL_TMP_SPACE_FULL";i[202]="HA_ERR_GLOBAL_TMP_SPACE_FULL";i[1e3]="ER_HASHCHK";i[1001]="ER_NISAMCHK";i[1002]="ER_NO";i[1003]="ER_YES";i[1004]="ER_CANT_CREATE_FILE";i[1005]="ER_CANT_CREATE_TABLE";i[1006]="ER_CANT_CREATE_DB";i[1007]="ER_DB_CREATE_EXISTS";i[1008]="ER_DB_DROP_EXISTS";i[1009]="ER_DB_DROP_DELETE";i[1010]="ER_DB_DROP_RMDIR";i[1011]="ER_CANT_DELETE_FILE";i[1012]="ER_CANT_FIND_SYSTEM_REC";i[1013]="ER_CANT_GET_STAT";i[1014]="ER_CANT_GET_WD";i[1015]="ER_CANT_LOCK";i[1016]="ER_CANT_OPEN_FILE";i[1017]="ER_FILE_NOT_FOUND";i[1018]="ER_CANT_READ_DIR";i[1019]="ER_CANT_SET_WD";i[1020]="ER_CHECKREAD";i[1021]="ER_DISK_FULL";i[1022]="ER_DUP_KEY";i[1023]="ER_ERROR_ON_CLOSE";i[1024]="ER_ERROR_ON_READ";i[1025]="ER_ERROR_ON_RENAME";i[1026]="ER_ERROR_ON_WRITE";i[1027]="ER_FILE_USED";i[1028]="ER_FILSORT_ABORT";i[1029]="ER_FORM_NOT_FOUND";i[1030]="ER_GET_ERRNO";i[1031]="ER_ILLEGAL_HA";i[1032]="ER_KEY_NOT_FOUND";i[1033]="ER_NOT_FORM_FILE";i[1034]="ER_NOT_KEYFILE";i[1035]="ER_OLD_KEYFILE";i[1036]="ER_OPEN_AS_READONLY";i[1037]="ER_OUTOFMEMORY";i[1038]="ER_OUT_OF_SORTMEMORY";i[1039]="ER_UNEXPECTED_EOF";i[1040]="ER_CON_COUNT_ERROR";i[1041]="ER_OUT_OF_RESOURCES";i[1042]="ER_BAD_HOST_ERROR";i[1043]="ER_HANDSHAKE_ERROR";i[1044]="ER_DBACCESS_DENIED_ERROR";i[1045]="ER_ACCESS_DENIED_ERROR";i[1046]="ER_NO_DB_ERROR";i[1047]="ER_UNKNOWN_COM_ERROR";i[1048]="ER_BAD_NULL_ERROR";i[1049]="ER_BAD_DB_ERROR";i[1050]="ER_TABLE_EXISTS_ERROR";i[1051]="ER_BAD_TABLE_ERROR";i[1052]="ER_NON_UNIQ_ERROR";i[1053]="ER_SERVER_SHUTDOWN";i[1054]="ER_BAD_FIELD_ERROR";i[1055]="ER_WRONG_FIELD_WITH_GROUP";i[1056]="ER_WRONG_GROUP_FIELD";i[1057]="ER_WRONG_SUM_SELECT";i[1058]="ER_WRONG_VALUE_COUNT";i[1059]="ER_TOO_LONG_IDENT";i[1060]="ER_DUP_FIELDNAME";i[1061]="ER_DUP_KEYNAME";i[1062]="ER_DUP_ENTRY";i[1063]="ER_WRONG_FIELD_SPEC";i[1064]="ER_PARSE_ERROR";i[1065]="ER_EMPTY_QUERY";i[1066]="ER_NONUNIQ_TABLE";i[1067]="ER_INVALID_DEFAULT";i[1068]="ER_MULTIPLE_PRI_KEY";i[1069]="ER_TOO_MANY_KEYS";i[1070]="ER_TOO_MANY_KEY_PARTS";i[1071]="ER_TOO_LONG_KEY";i[1072]="ER_KEY_COLUMN_DOES_NOT_EXIST";i[1073]="ER_BLOB_USED_AS_KEY";i[1074]="ER_TOO_BIG_FIELDLENGTH";i[1075]="ER_WRONG_AUTO_KEY";i[1076]="ER_BINLOG_CANT_DELETE_GTID_DOMAIN";i[1077]="ER_NORMAL_SHUTDOWN";i[1078]="ER_GOT_SIGNAL";i[1079]="ER_SHUTDOWN_COMPLETE";i[1080]="ER_FORCING_CLOSE";i[1081]="ER_IPSOCK_ERROR";i[1082]="ER_NO_SUCH_INDEX";i[1083]="ER_WRONG_FIELD_TERMINATORS";i[1084]="ER_BLOBS_AND_NO_TERMINATED";i[1085]="ER_TEXTFILE_NOT_READABLE";i[1086]="ER_FILE_EXISTS_ERROR";i[1087]="ER_LOAD_INFO";i[1088]="ER_ALTER_INFO";i[1089]="ER_WRONG_SUB_KEY";i[1090]="ER_CANT_REMOVE_ALL_FIELDS";i[1091]="ER_CANT_DROP_FIELD_OR_KEY";i[1092]="ER_INSERT_INFO";i[1093]="ER_UPDATE_TABLE_USED";i[1094]="ER_NO_SUCH_THREAD";i[1095]="ER_KILL_DENIED_ERROR";i[1096]="ER_NO_TABLES_USED";i[1097]="ER_TOO_BIG_SET";i[1098]="ER_NO_UNIQUE_LOGFILE";i[1099]="ER_TABLE_NOT_LOCKED_FOR_WRITE";i[1100]="ER_TABLE_NOT_LOCKED";i[1101]="ER_UNUSED_17";i[1102]="ER_WRONG_DB_NAME";i[1103]="ER_WRONG_TABLE_NAME";i[1104]="ER_TOO_BIG_SELECT";i[1105]="ER_UNKNOWN_ERROR";i[1106]="ER_UNKNOWN_PROCEDURE";i[1107]="ER_WRONG_PARAMCOUNT_TO_PROCEDURE";i[1108]="ER_WRONG_PARAMETERS_TO_PROCEDURE";i[1109]="ER_UNKNOWN_TABLE";i[1110]="ER_FIELD_SPECIFIED_TWICE";i[1111]="ER_INVALID_GROUP_FUNC_USE";i[1112]="ER_UNSUPPORTED_EXTENSION";i[1113]="ER_TABLE_MUST_HAVE_COLUMNS";i[1114]="ER_RECORD_FILE_FULL";i[1115]="ER_UNKNOWN_CHARACTER_SET";i[1116]="ER_TOO_MANY_TABLES";i[1117]="ER_TOO_MANY_FIELDS";i[1118]="ER_TOO_BIG_ROWSIZE";i[1119]="ER_STACK_OVERRUN";i[1120]="ER_WRONG_OUTER_JOIN";i[1121]="ER_NULL_COLUMN_IN_INDEX";i[1122]="ER_CANT_FIND_UDF";i[1123]="ER_CANT_INITIALIZE_UDF";i[1124]="ER_UDF_NO_PATHS";i[1125]="ER_UDF_EXISTS";i[1126]="ER_CANT_OPEN_LIBRARY";i[1127]="ER_CANT_FIND_DL_ENTRY";i[1128]="ER_FUNCTION_NOT_DEFINED";i[1129]="ER_HOST_IS_BLOCKED";i[1130]="ER_HOST_NOT_PRIVILEGED";i[1131]="ER_PASSWORD_ANONYMOUS_USER";i[1132]="ER_PASSWORD_NOT_ALLOWED";i[1133]="ER_PASSWORD_NO_MATCH";i[1134]="ER_UPDATE_INFO";i[1135]="ER_CANT_CREATE_THREAD";i[1136]="ER_WRONG_VALUE_COUNT_ON_ROW";i[1137]="ER_CANT_REOPEN_TABLE";i[1138]="ER_INVALID_USE_OF_NULL";i[1139]="ER_REGEXP_ERROR";i[1140]="ER_MIX_OF_GROUP_FUNC_AND_FIELDS";i[1141]="ER_NONEXISTING_GRANT";i[1142]="ER_TABLEACCESS_DENIED_ERROR";i[1143]="ER_COLUMNACCESS_DENIED_ERROR";i[1144]="ER_ILLEGAL_GRANT_FOR_TABLE";i[1145]="ER_GRANT_WRONG_HOST_OR_USER";i[1146]="ER_NO_SUCH_TABLE";i[1147]="ER_NONEXISTING_TABLE_GRANT";i[1148]="ER_NOT_ALLOWED_COMMAND";i[1149]="ER_SYNTAX_ERROR";i[1150]="ER_DELAYED_CANT_CHANGE_LOCK";i[1151]="ER_TOO_MANY_DELAYED_THREADS";i[1152]="ER_ABORTING_CONNECTION";i[1153]="ER_NET_PACKET_TOO_LARGE";i[1154]="ER_NET_READ_ERROR_FROM_PIPE";i[1155]="ER_NET_FCNTL_ERROR";i[1156]="ER_NET_PACKETS_OUT_OF_ORDER";i[1157]="ER_NET_UNCOMPRESS_ERROR";i[1158]="ER_NET_READ_ERROR";i[1159]="ER_NET_READ_INTERRUPTED";i[1160]="ER_NET_ERROR_ON_WRITE";i[1161]="ER_NET_WRITE_INTERRUPTED";i[1162]="ER_TOO_LONG_STRING";i[1163]="ER_TABLE_CANT_HANDLE_BLOB";i[1164]="ER_TABLE_CANT_HANDLE_AUTO_INCREMENT";i[1165]="ER_DELAYED_INSERT_TABLE_LOCKED";i[1166]="ER_WRONG_COLUMN_NAME";i[1167]="ER_WRONG_KEY_COLUMN";i[1168]="ER_WRONG_MRG_TABLE";i[1169]="ER_DUP_UNIQUE";i[1170]="ER_BLOB_KEY_WITHOUT_LENGTH";i[1171]="ER_PRIMARY_CANT_HAVE_NULL";i[1172]="ER_TOO_MANY_ROWS";i[1173]="ER_REQUIRES_PRIMARY_KEY";i[1174]="ER_NO_RAID_COMPILED";i[1175]="ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE";i[1176]="ER_KEY_DOES_NOT_EXISTS";i[1177]="ER_CHECK_NO_SUCH_TABLE";i[1178]="ER_CHECK_NOT_IMPLEMENTED";i[1179]="ER_CANT_DO_THIS_DURING_AN_TRANSACTION";i[1180]="ER_ERROR_DURING_COMMIT";i[1181]="ER_ERROR_DURING_ROLLBACK";i[1182]="ER_ERROR_DURING_FLUSH_LOGS";i[1183]="ER_ERROR_DURING_CHECKPOINT";i[1184]="ER_NEW_ABORTING_CONNECTION";i[1185]="ER_UNUSED_10";i[1186]="ER_FLUSH_MASTER_BINLOG_CLOSED";i[1187]="ER_INDEX_REBUILD";i[1188]="ER_MASTER";i[1189]="ER_MASTER_NET_READ";i[1190]="ER_MASTER_NET_WRITE";i[1191]="ER_FT_MATCHING_KEY_NOT_FOUND";i[1192]="ER_LOCK_OR_ACTIVE_TRANSACTION";i[1193]="ER_UNKNOWN_SYSTEM_VARIABLE";i[1194]="ER_CRASHED_ON_USAGE";i[1195]="ER_CRASHED_ON_REPAIR";i[1196]="ER_WARNING_NOT_COMPLETE_ROLLBACK";i[1197]="ER_TRANS_CACHE_FULL";i[1198]="ER_SLAVE_MUST_STOP";i[1199]="ER_SLAVE_NOT_RUNNING";i[1200]="ER_BAD_SLAVE";i[1201]="ER_MASTER_INFO";i[1202]="ER_SLAVE_THREAD";i[1203]="ER_TOO_MANY_USER_CONNECTIONS";i[1204]="ER_SET_CONSTANTS_ONLY";i[1205]="ER_LOCK_WAIT_TIMEOUT";i[1206]="ER_LOCK_TABLE_FULL";i[1207]="ER_READ_ONLY_TRANSACTION";i[1208]="ER_DROP_DB_WITH_READ_LOCK";i[1209]="ER_CREATE_DB_WITH_READ_LOCK";i[1210]="ER_WRONG_ARGUMENTS";i[1211]="ER_NO_PERMISSION_TO_CREATE_USER";i[1212]="ER_UNION_TABLES_IN_DIFFERENT_DIR";i[1213]="ER_LOCK_DEADLOCK";i[1214]="ER_TABLE_CANT_HANDLE_FT";i[1215]="ER_CANNOT_ADD_FOREIGN";i[1216]="ER_NO_REFERENCED_ROW";i[1217]="ER_ROW_IS_REFERENCED";i[1218]="ER_CONNECT_TO_MASTER";i[1219]="ER_QUERY_ON_MASTER";i[1220]="ER_ERROR_WHEN_EXECUTING_COMMAND";i[1221]="ER_WRONG_USAGE";i[1222]="ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT";i[1223]="ER_CANT_UPDATE_WITH_READLOCK";i[1224]="ER_MIXING_NOT_ALLOWED";i[1225]="ER_DUP_ARGUMENT";i[1226]="ER_USER_LIMIT_REACHED";i[1227]="ER_SPECIFIC_ACCESS_DENIED_ERROR";i[1228]="ER_LOCAL_VARIABLE";i[1229]="ER_GLOBAL_VARIABLE";i[1230]="ER_NO_DEFAULT";i[1231]="ER_WRONG_VALUE_FOR_VAR";i[1232]="ER_WRONG_TYPE_FOR_VAR";i[1233]="ER_VAR_CANT_BE_READ";i[1234]="ER_CANT_USE_OPTION_HERE";i[1235]="ER_NOT_SUPPORTED_YET";i[1236]="ER_MASTER_FATAL_ERROR_READING_BINLOG";i[1237]="ER_SLAVE_IGNORED_TABLE";i[1238]="ER_INCORRECT_GLOBAL_LOCAL_VAR";i[1239]="ER_WRONG_FK_DEF";i[1240]="ER_KEY_REF_DO_NOT_MATCH_TABLE_REF";i[1241]="ER_OPERAND_COLUMNS";i[1242]="ER_SUBQUERY_NO_1_ROW";i[1243]="ER_UNKNOWN_STMT_HANDLER";i[1244]="ER_CORRUPT_HELP_DB";i[1245]="ER_CYCLIC_REFERENCE";i[1246]="ER_AUTO_CONVERT";i[1247]="ER_ILLEGAL_REFERENCE";i[1248]="ER_DERIVED_MUST_HAVE_ALIAS";i[1249]="ER_SELECT_REDUCED";i[1250]="ER_TABLENAME_NOT_ALLOWED_HERE";i[1251]="ER_NOT_SUPPORTED_AUTH_MODE";i[1252]="ER_INDEX_CANNOT_HAVE_NULL";i[1253]="ER_COLLATION_CHARSET_MISMATCH";i[1254]="ER_SLAVE_WAS_RUNNING";i[1255]="ER_SLAVE_WAS_NOT_RUNNING";i[1256]="ER_TOO_BIG_FOR_UNCOMPRESS";i[1257]="ER_ZLIB_Z_MEM_ERROR";i[1258]="ER_ZLIB_Z_BUF_ERROR";i[1259]="ER_ZLIB_Z_DATA_ERROR";i[1260]="ER_CUT_VALUE_GROUP_CONCAT";i[1261]="ER_WARN_TOO_FEW_RECORDS";i[1262]="ER_WARN_TOO_MANY_RECORDS";i[1263]="ER_WARN_NULL_TO_NOTNULL";i[1264]="ER_WARN_DATA_OUT_OF_RANGE";i[1265]="WARN_DATA_TRUNCATED";i[1266]="ER_WARN_USING_OTHER_HANDLER";i[1267]="ER_CANT_AGGREGATE_2COLLATIONS";i[1268]="ER_DROP_USER";i[1269]="ER_REVOKE_GRANTS";i[1270]="ER_CANT_AGGREGATE_3COLLATIONS";i[1271]="ER_CANT_AGGREGATE_NCOLLATIONS";i[1272]="ER_VARIABLE_IS_NOT_STRUCT";i[1273]="ER_UNKNOWN_COLLATION";i[1274]="ER_SLAVE_IGNORED_SSL_PARAMS";i[1275]="ER_SERVER_IS_IN_SECURE_AUTH_MODE";i[1276]="ER_WARN_FIELD_RESOLVED";i[1277]="ER_BAD_SLAVE_UNTIL_COND";i[1278]="ER_MISSING_SKIP_SLAVE";i[1279]="ER_UNTIL_COND_IGNORED";i[1280]="ER_WRONG_NAME_FOR_INDEX";i[1281]="ER_WRONG_NAME_FOR_CATALOG";i[1282]="ER_WARN_QC_RESIZE";i[1283]="ER_BAD_FT_COLUMN";i[1284]="ER_UNKNOWN_KEY_CACHE";i[1285]="ER_WARN_HOSTNAME_WONT_WORK";i[1286]="ER_UNKNOWN_STORAGE_ENGINE";i[1287]="ER_WARN_DEPRECATED_SYNTAX";i[1288]="ER_NON_UPDATABLE_TABLE";i[1289]="ER_FEATURE_DISABLED";i[1290]="ER_OPTION_PREVENTS_STATEMENT";i[1291]="ER_DUPLICATED_VALUE_IN_TYPE";i[1292]="ER_TRUNCATED_WRONG_VALUE";i[1293]="ER_TOO_MUCH_AUTO_TIMESTAMP_COLS";i[1294]="ER_INVALID_ON_UPDATE";i[1295]="ER_UNSUPPORTED_PS";i[1296]="ER_GET_ERRMSG";i[1297]="ER_GET_TEMPORARY_ERRMSG";i[1298]="ER_UNKNOWN_TIME_ZONE";i[1299]="ER_WARN_INVALID_TIMESTAMP";i[1300]="ER_INVALID_CHARACTER_STRING";i[1301]="ER_WARN_ALLOWED_PACKET_OVERFLOWED";i[1302]="ER_CONFLICTING_DECLARATIONS";i[1303]="ER_SP_NO_RECURSIVE_CREATE";i[1304]="ER_SP_ALREADY_EXISTS";i[1305]="ER_SP_DOES_NOT_EXIST";i[1306]="ER_SP_DROP_FAILED";i[1307]="ER_SP_STORE_FAILED";i[1308]="ER_SP_LILABEL_MISMATCH";i[1309]="ER_SP_LABEL_REDEFINE";i[1310]="ER_SP_LABEL_MISMATCH";i[1311]="ER_SP_UNINIT_VAR";i[1312]="ER_SP_BADSELECT";i[1313]="ER_SP_BADRETURN";i[1314]="ER_SP_BADSTATEMENT";i[1315]="ER_UPDATE_LOG_DEPRECATED_IGNORED";i[1316]="ER_UPDATE_LOG_DEPRECATED_TRANSLATED";i[1317]="ER_QUERY_INTERRUPTED";i[1318]="ER_SP_WRONG_NO_OF_ARGS";i[1319]="ER_SP_COND_MISMATCH";i[1320]="ER_SP_NORETURN";i[1321]="ER_SP_NORETURNEND";i[1322]="ER_SP_BAD_CURSOR_QUERY";i[1323]="ER_SP_BAD_CURSOR_SELECT";i[1324]="ER_SP_CURSOR_MISMATCH";i[1325]="ER_SP_CURSOR_ALREADY_OPEN";i[1326]="ER_SP_CURSOR_NOT_OPEN";i[1327]="ER_SP_UNDECLARED_VAR";i[1328]="ER_SP_WRONG_NO_OF_FETCH_ARGS";i[1329]="ER_SP_FETCH_NO_DATA";i[1330]="ER_SP_DUP_PARAM";i[1331]="ER_SP_DUP_VAR";i[1332]="ER_SP_DUP_COND";i[1333]="ER_SP_DUP_CURS";i[1334]="ER_SP_CANT_ALTER";i[1335]="ER_SP_SUBSELECT_NYI";i[1336]="ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG";i[1337]="ER_SP_VARCOND_AFTER_CURSHNDLR";i[1338]="ER_SP_CURSOR_AFTER_HANDLER";i[1339]="ER_SP_CASE_NOT_FOUND";i[1340]="ER_FPARSER_TOO_BIG_FILE";i[1341]="ER_FPARSER_BAD_HEADER";i[1342]="ER_FPARSER_EOF_IN_COMMENT";i[1343]="ER_FPARSER_ERROR_IN_PARAMETER";i[1344]="ER_FPARSER_EOF_IN_UNKNOWN_PARAMETER";i[1345]="ER_VIEW_NO_EXPLAIN";i[1346]="ER_FRM_UNKNOWN_TYPE";i[1347]="ER_WRONG_OBJECT";i[1348]="ER_NONUPDATEABLE_COLUMN";i[1349]="ER_VIEW_SELECT_DERIVED";i[1350]="ER_VIEW_SELECT_CLAUSE";i[1351]="ER_VIEW_SELECT_VARIABLE";i[1352]="ER_VIEW_SELECT_TMPTABLE";i[1353]="ER_VIEW_WRONG_LIST";i[1354]="ER_WARN_VIEW_MERGE";i[1355]="ER_WARN_VIEW_WITHOUT_KEY";i[1356]="ER_VIEW_INVALID";i[1357]="ER_SP_NO_DROP_SP";i[1358]="ER_SP_GOTO_IN_HNDLR";i[1359]="ER_TRG_ALREADY_EXISTS";i[1360]="ER_TRG_DOES_NOT_EXIST";i[1361]="ER_TRG_ON_VIEW_OR_TEMP_TABLE";i[1362]="ER_TRG_CANT_CHANGE_ROW";i[1363]="ER_TRG_NO_SUCH_ROW_IN_TRG";i[1364]="ER_NO_DEFAULT_FOR_FIELD";i[1365]="ER_DIVISION_BY_ZERO";i[1366]="ER_TRUNCATED_WRONG_VALUE_FOR_FIELD";i[1367]="ER_ILLEGAL_VALUE_FOR_TYPE";i[1368]="ER_VIEW_NONUPD_CHECK";i[1369]="ER_VIEW_CHECK_FAILED";i[1370]="ER_PROCACCESS_DENIED_ERROR";i[1371]="ER_RELAY_LOG_FAIL";i[1372]="ER_PASSWD_LENGTH";i[1373]="ER_UNKNOWN_TARGET_BINLOG";i[1374]="ER_IO_ERR_LOG_INDEX_READ";i[1375]="ER_BINLOG_PURGE_PROHIBITED";i[1376]="ER_FSEEK_FAIL";i[1377]="ER_BINLOG_PURGE_FATAL_ERR";i[1378]="ER_LOG_IN_USE";i[1379]="ER_LOG_PURGE_UNKNOWN_ERR";i[1380]="ER_RELAY_LOG_INIT";i[1381]="ER_NO_BINARY_LOGGING";i[1382]="ER_RESERVED_SYNTAX";i[1383]="ER_WSAS_FAILED";i[1384]="ER_DIFF_GROUPS_PROC";i[1385]="ER_NO_GROUP_FOR_PROC";i[1386]="ER_ORDER_WITH_PROC";i[1387]="ER_LOGGING_PROHIBIT_CHANGING_OF";i[1388]="ER_NO_FILE_MAPPING";i[1389]="ER_WRONG_MAGIC";i[1390]="ER_PS_MANY_PARAM";i[1391]="ER_KEY_PART_0";i[1392]="ER_VIEW_CHECKSUM";i[1393]="ER_VIEW_MULTIUPDATE";i[1394]="ER_VIEW_NO_INSERT_FIELD_LIST";i[1395]="ER_VIEW_DELETE_MERGE_VIEW";i[1396]="ER_CANNOT_USER";i[1397]="ER_XAER_NOTA";i[1398]="ER_XAER_INVAL";i[1399]="ER_XAER_RMFAIL";i[1400]="ER_XAER_OUTSIDE";i[1401]="ER_XAER_RMERR";i[1402]="ER_XA_RBROLLBACK";i[1403]="ER_NONEXISTING_PROC_GRANT";i[1404]="ER_PROC_AUTO_GRANT_FAIL";i[1405]="ER_PROC_AUTO_REVOKE_FAIL";i[1406]="ER_DATA_TOO_LONG";i[1407]="ER_SP_BAD_SQLSTATE";i[1408]="ER_STARTUP";i[1409]="ER_LOAD_FROM_FIXED_SIZE_ROWS_TO_VAR";i[1410]="ER_CANT_CREATE_USER_WITH_GRANT";i[1411]="ER_WRONG_VALUE_FOR_TYPE";i[1412]="ER_TABLE_DEF_CHANGED";i[1413]="ER_SP_DUP_HANDLER";i[1414]="ER_SP_NOT_VAR_ARG";i[1415]="ER_SP_NO_RETSET";i[1416]="ER_CANT_CREATE_GEOMETRY_OBJECT";i[1417]="ER_FAILED_ROUTINE_BREAK_BINLOG";i[1418]="ER_BINLOG_UNSAFE_ROUTINE";i[1419]="ER_BINLOG_CREATE_ROUTINE_NEED_SUPER";i[1420]="ER_EXEC_STMT_WITH_OPEN_CURSOR";i[1421]="ER_STMT_HAS_NO_OPEN_CURSOR";i[1422]="ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG";i[1423]="ER_NO_DEFAULT_FOR_VIEW_FIELD";i[1424]="ER_SP_NO_RECURSION";i[1425]="ER_TOO_BIG_SCALE";i[1426]="ER_TOO_BIG_PRECISION";i[1427]="ER_M_BIGGER_THAN_D";i[1428]="ER_WRONG_LOCK_OF_SYSTEM_TABLE";i[1429]="ER_CONNECT_TO_FOREIGN_DATA_SOURCE";i[1430]="ER_QUERY_ON_FOREIGN_DATA_SOURCE";i[1431]="ER_FOREIGN_DATA_SOURCE_DOESNT_EXIST";i[1432]="ER_FOREIGN_DATA_STRING_INVALID_CANT_CREATE";i[1433]="ER_FOREIGN_DATA_STRING_INVALID";i[1434]="ER_CANT_CREATE_FEDERATED_TABLE";i[1435]="ER_TRG_IN_WRONG_SCHEMA";i[1436]="ER_STACK_OVERRUN_NEED_MORE";i[1437]="ER_TOO_LONG_BODY";i[1438]="ER_WARN_CANT_DROP_DEFAULT_KEYCACHE";i[1439]="ER_TOO_BIG_DISPLAYWIDTH";i[1440]="ER_XAER_DUPID";i[1441]="ER_DATETIME_FUNCTION_OVERFLOW";i[1442]="ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG";i[1443]="ER_VIEW_PREVENT_UPDATE";i[1444]="ER_PS_NO_RECURSION";i[1445]="ER_SP_CANT_SET_AUTOCOMMIT";i[1446]="ER_MALFORMED_DEFINER";i[1447]="ER_VIEW_FRM_NO_USER";i[1448]="ER_UNUSED_30";i[1449]="ER_NO_SUCH_USER";i[1450]="ER_FORBID_SCHEMA_CHANGE";i[1451]="ER_ROW_IS_REFERENCED_2";i[1452]="ER_NO_REFERENCED_ROW_2";i[1453]="ER_SP_BAD_VAR_SHADOW";i[1454]="ER_TRG_NO_DEFINER";i[1455]="ER_OLD_FILE_FORMAT";i[1456]="ER_SP_RECURSION_LIMIT";i[1457]="ER_SP_PROC_TABLE_CORRUPT";i[1458]="ER_SP_WRONG_NAME";i[1459]="ER_TABLE_NEEDS_UPGRADE";i[1460]="ER_SP_NO_AGGREGATE";i[1461]="ER_MAX_PREPARED_STMT_COUNT_REACHED";i[1462]="ER_VIEW_RECURSIVE";i[1463]="ER_NON_GROUPING_FIELD_USED";i[1464]="ER_TABLE_CANT_HANDLE_SPKEYS";i[1465]="ER_NO_TRIGGERS_ON_SYSTEM_SCHEMA";i[1466]="ER_REMOVED_SPACES";i[1467]="ER_AUTOINC_READ_FAILED";i[1468]="ER_USERNAME";i[1469]="ER_HOSTNAME";i[1470]="ER_WRONG_STRING_LENGTH";i[1471]="ER_NON_INSERTABLE_TABLE";i[1472]="ER_ADMIN_WRONG_MRG_TABLE";i[1473]="ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT";i[1474]="ER_NAME_BECOMES_EMPTY";i[1475]="ER_AMBIGUOUS_FIELD_TERM";i[1476]="ER_FOREIGN_SERVER_EXISTS";i[1477]="ER_FOREIGN_SERVER_DOESNT_EXIST";i[1478]="ER_ILLEGAL_HA_CREATE_OPTION";i[1479]="ER_PARTITION_REQUIRES_VALUES_ERROR";i[1480]="ER_PARTITION_WRONG_VALUES_ERROR";i[1481]="ER_PARTITION_MAXVALUE_ERROR";i[1482]="ER_PARTITION_SUBPARTITION_ERROR";i[1483]="ER_PARTITION_SUBPART_MIX_ERROR";i[1484]="ER_PARTITION_WRONG_NO_PART_ERROR";i[1485]="ER_PARTITION_WRONG_NO_SUBPART_ERROR";i[1486]="ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR";i[1487]="ER_NOT_CONSTANT_EXPRESSION";i[1488]="ER_FIELD_NOT_FOUND_PART_ERROR";i[1489]="ER_LIST_OF_FIELDS_ONLY_IN_HASH_ERROR";i[1490]="ER_INCONSISTENT_PARTITION_INFO_ERROR";i[1491]="ER_PARTITION_FUNC_NOT_ALLOWED_ERROR";i[1492]="ER_PARTITIONS_MUST_BE_DEFINED_ERROR";i[1493]="ER_RANGE_NOT_INCREASING_ERROR";i[1494]="ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR";i[1495]="ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR";i[1496]="ER_PARTITION_ENTRY_ERROR";i[1497]="ER_MIX_HANDLER_ERROR";i[1498]="ER_PARTITION_NOT_DEFINED_ERROR";i[1499]="ER_TOO_MANY_PARTITIONS_ERROR";i[1500]="ER_SUBPARTITION_ERROR";i[1501]="ER_CANT_CREATE_HANDLER_FILE";i[1502]="ER_BLOB_FIELD_IN_PART_FUNC_ERROR";i[1503]="ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF";i[1504]="ER_NO_PARTS_ERROR";i[1505]="ER_PARTITION_MGMT_ON_NONPARTITIONED";i[1506]="ER_FEATURE_NOT_SUPPORTED_WITH_PARTITIONING";i[1507]="ER_PARTITION_DOES_NOT_EXIST";i[1508]="ER_DROP_LAST_PARTITION";i[1509]="ER_COALESCE_ONLY_ON_HASH_PARTITION";i[1510]="ER_REORG_HASH_ONLY_ON_SAME_NO";i[1511]="ER_REORG_NO_PARAM_ERROR";i[1512]="ER_ONLY_ON_RANGE_LIST_PARTITION";i[1513]="ER_ADD_PARTITION_SUBPART_ERROR";i[1514]="ER_ADD_PARTITION_NO_NEW_PARTITION";i[1515]="ER_COALESCE_PARTITION_NO_PARTITION";i[1516]="ER_REORG_PARTITION_NOT_EXIST";i[1517]="ER_SAME_NAME_PARTITION";i[1518]="ER_NO_BINLOG_ERROR";i[1519]="ER_CONSECUTIVE_REORG_PARTITIONS";i[1520]="ER_REORG_OUTSIDE_RANGE";i[1521]="ER_PARTITION_FUNCTION_FAILURE";i[1522]="ER_PART_STATE_ERROR";i[1523]="ER_LIMITED_PART_RANGE";i[1524]="ER_PLUGIN_IS_NOT_LOADED";i[1525]="ER_WRONG_VALUE";i[1526]="ER_NO_PARTITION_FOR_GIVEN_VALUE";i[1527]="ER_FILEGROUP_OPTION_ONLY_ONCE";i[1528]="ER_CREATE_FILEGROUP_FAILED";i[1529]="ER_DROP_FILEGROUP_FAILED";i[1530]="ER_TABLESPACE_AUTO_EXTEND_ERROR";i[1531]="ER_WRONG_SIZE_NUMBER";i[1532]="ER_SIZE_OVERFLOW_ERROR";i[1533]="ER_ALTER_FILEGROUP_FAILED";i[1534]="ER_BINLOG_ROW_LOGGING_FAILED";i[1535]="ER_BINLOG_ROW_WRONG_TABLE_DEF";i[1536]="ER_BINLOG_ROW_RBR_TO_SBR";i[1537]="ER_EVENT_ALREADY_EXISTS";i[1538]="ER_EVENT_STORE_FAILED";i[1539]="ER_EVENT_DOES_NOT_EXIST";i[1540]="ER_EVENT_CANT_ALTER";i[1541]="ER_EVENT_DROP_FAILED";i[1542]="ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG";i[1543]="ER_EVENT_ENDS_BEFORE_STARTS";i[1544]="ER_EVENT_EXEC_TIME_IN_THE_PAST";i[1545]="ER_EVENT_OPEN_TABLE_FAILED";i[1546]="ER_EVENT_NEITHER_M_EXPR_NOR_M_AT";i[1547]="ER_UNUSED_2";i[1548]="ER_UNUSED_3";i[1549]="ER_EVENT_CANNOT_DELETE";i[1550]="ER_EVENT_COMPILE_ERROR";i[1551]="ER_EVENT_SAME_NAME";i[1552]="ER_EVENT_DATA_TOO_LONG";i[1553]="ER_DROP_INDEX_FK";i[1554]="ER_WARN_DEPRECATED_SYNTAX_WITH_VER";i[1555]="ER_CANT_WRITE_LOCK_LOG_TABLE";i[1556]="ER_CANT_LOCK_LOG_TABLE";i[1557]="ER_UNUSED_4";i[1558]="ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE";i[1559]="ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR";i[1560]="ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT";i[1561]="ER_UNUSED_13";i[1562]="ER_PARTITION_NO_TEMPORARY";i[1563]="ER_PARTITION_CONST_DOMAIN_ERROR";i[1564]="ER_PARTITION_FUNCTION_IS_NOT_ALLOWED";i[1565]="ER_DDL_LOG_ERROR";i[1566]="ER_NULL_IN_VALUES_LESS_THAN";i[1567]="ER_WRONG_PARTITION_NAME";i[1568]="ER_CANT_SET_IN_TRANSACTION";i[1569]="ER_DUP_ENTRY_AUTOINCREMENT_CASE";i[1570]="ER_EVENT_MODIFY_QUEUE_ERROR";i[1571]="ER_EVENT_SET_VAR_ERROR";i[1572]="ER_PARTITION_MERGE_ERROR";i[1573]="ER_CANT_ACTIVATE_LOG";i[1574]="ER_RBR_NOT_AVAILABLE";i[1575]="ER_BASE64_DECODE_ERROR";i[1576]="ER_EVENT_RECURSION_FORBIDDEN";i[1577]="ER_EVENTS_DB_ERROR";i[1578]="ER_ONLY_INTEGERS_ALLOWED";i[1579]="ER_UNSUPORTED_LOG_ENGINE";i[1580]="ER_BAD_LOG_STATEMENT";i[1581]="ER_CANT_RENAME_LOG_TABLE";i[1582]="ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT";i[1583]="ER_WRONG_PARAMETERS_TO_NATIVE_FCT";i[1584]="ER_WRONG_PARAMETERS_TO_STORED_FCT";i[1585]="ER_NATIVE_FCT_NAME_COLLISION";i[1586]="ER_DUP_ENTRY_WITH_KEY_NAME";i[1587]="ER_BINLOG_PURGE_EMFILE";i[1588]="ER_EVENT_CANNOT_CREATE_IN_THE_PAST";i[1589]="ER_EVENT_CANNOT_ALTER_IN_THE_PAST";i[1590]="ER_SLAVE_INCIDENT";i[1591]="ER_NO_PARTITION_FOR_GIVEN_VALUE_SILENT";i[1592]="ER_BINLOG_UNSAFE_STATEMENT";i[1593]="ER_SLAVE_FATAL_ERROR";i[1594]="ER_SLAVE_RELAY_LOG_READ_FAILURE";i[1595]="ER_SLAVE_RELAY_LOG_WRITE_FAILURE";i[1596]="ER_SLAVE_CREATE_EVENT_FAILURE";i[1597]="ER_SLAVE_MASTER_COM_FAILURE";i[1598]="ER_BINLOG_LOGGING_IMPOSSIBLE";i[1599]="ER_VIEW_NO_CREATION_CTX";i[1600]="ER_VIEW_INVALID_CREATION_CTX";i[1601]="ER_SR_INVALID_CREATION_CTX";i[1602]="ER_TRG_CORRUPTED_FILE";i[1603]="ER_TRG_NO_CREATION_CTX";i[1604]="ER_TRG_INVALID_CREATION_CTX";i[1605]="ER_EVENT_INVALID_CREATION_CTX";i[1606]="ER_TRG_CANT_OPEN_TABLE";i[1607]="ER_CANT_CREATE_SROUTINE";i[1608]="ER_UNUSED_11";i[1609]="ER_NO_FORMAT_DESCRIPTION_EVENT_BEFORE_BINLOG_STATEMENT";i[1610]="ER_SLAVE_CORRUPT_EVENT";i[1611]="ER_LOAD_DATA_INVALID_COLUMN";i[1612]="ER_LOG_PURGE_NO_FILE";i[1613]="ER_XA_RBTIMEOUT";i[1614]="ER_XA_RBDEADLOCK";i[1615]="ER_NEED_REPREPARE";i[1616]="ER_DELAYED_NOT_SUPPORTED";i[1617]="WARN_NO_MASTER_INFO";i[1618]="WARN_OPTION_IGNORED";i[1619]="ER_PLUGIN_DELETE_BUILTIN";i[1620]="WARN_PLUGIN_BUSY";i[1621]="ER_VARIABLE_IS_READONLY";i[1622]="ER_WARN_ENGINE_TRANSACTION_ROLLBACK";i[1623]="ER_SLAVE_HEARTBEAT_FAILURE";i[1624]="ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE";i[1625]="ER_UNUSED_14";i[1626]="ER_CONFLICT_FN_PARSE_ERROR";i[1627]="ER_EXCEPTIONS_WRITE_ERROR";i[1628]="ER_TOO_LONG_TABLE_COMMENT";i[1629]="ER_TOO_LONG_FIELD_COMMENT";i[1630]="ER_FUNC_INEXISTENT_NAME_COLLISION";i[1631]="ER_DATABASE_NAME";i[1632]="ER_TABLE_NAME";i[1633]="ER_PARTITION_NAME";i[1634]="ER_SUBPARTITION_NAME";i[1635]="ER_TEMPORARY_NAME";i[1636]="ER_RENAMED_NAME";i[1637]="ER_TOO_MANY_CONCURRENT_TRXS";i[1638]="WARN_NON_ASCII_SEPARATOR_NOT_IMPLEMENTED";i[1639]="ER_DEBUG_SYNC_TIMEOUT";i[1640]="ER_DEBUG_SYNC_HIT_LIMIT";i[1641]="ER_DUP_SIGNAL_SET";i[1642]="ER_SIGNAL_WARN";i[1643]="ER_SIGNAL_NOT_FOUND";i[1644]="ER_SIGNAL_EXCEPTION";i[1645]="ER_RESIGNAL_WITHOUT_ACTIVE_HANDLER";i[1646]="ER_SIGNAL_BAD_CONDITION_TYPE";i[1647]="WARN_COND_ITEM_TRUNCATED";i[1648]="ER_COND_ITEM_TOO_LONG";i[1649]="ER_UNKNOWN_LOCALE";i[1650]="ER_SLAVE_IGNORE_SERVER_IDS";i[1651]="ER_QUERY_CACHE_DISABLED";i[1652]="ER_SAME_NAME_PARTITION_FIELD";i[1653]="ER_PARTITION_COLUMN_LIST_ERROR";i[1654]="ER_WRONG_TYPE_COLUMN_VALUE_ERROR";i[1655]="ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR";i[1656]="ER_MAXVALUE_IN_VALUES_IN";i[1657]="ER_TOO_MANY_VALUES_ERROR";i[1658]="ER_ROW_SINGLE_PARTITION_FIELD_ERROR";i[1659]="ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD";i[1660]="ER_PARTITION_FIELDS_TOO_LONG";i[1661]="ER_BINLOG_ROW_ENGINE_AND_STMT_ENGINE";i[1662]="ER_BINLOG_ROW_MODE_AND_STMT_ENGINE";i[1663]="ER_BINLOG_UNSAFE_AND_STMT_ENGINE";i[1664]="ER_BINLOG_ROW_INJECTION_AND_STMT_ENGINE";i[1665]="ER_BINLOG_STMT_MODE_AND_ROW_ENGINE";i[1666]="ER_BINLOG_ROW_INJECTION_AND_STMT_MODE";i[1667]="ER_BINLOG_MULTIPLE_ENGINES_AND_SELF_LOGGING_ENGINE";i[1668]="ER_BINLOG_UNSAFE_LIMIT";i[1669]="ER_BINLOG_UNSAFE_INSERT_DELAYED";i[1670]="ER_BINLOG_UNSAFE_SYSTEM_TABLE";i[1671]="ER_BINLOG_UNSAFE_AUTOINC_COLUMNS";i[1672]="ER_BINLOG_UNSAFE_UDF";i[1673]="ER_BINLOG_UNSAFE_SYSTEM_VARIABLE";i[1674]="ER_BINLOG_UNSAFE_SYSTEM_FUNCTION";i[1675]="ER_BINLOG_UNSAFE_NONTRANS_AFTER_TRANS";i[1676]="ER_MESSAGE_AND_STATEMENT";i[1677]="ER_SLAVE_CONVERSION_FAILED";i[1678]="ER_SLAVE_CANT_CREATE_CONVERSION";i[1679]="ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_FORMAT";i[1680]="ER_PATH_LENGTH";i[1681]="ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT";i[1682]="ER_WRONG_NATIVE_TABLE_STRUCTURE";i[1683]="ER_WRONG_PERFSCHEMA_USAGE";i[1684]="ER_WARN_I_S_SKIPPED_TABLE";i[1685]="ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_DIRECT";i[1686]="ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_DIRECT";i[1687]="ER_SPATIAL_MUST_HAVE_GEOM_COL";i[1688]="ER_TOO_LONG_INDEX_COMMENT";i[1689]="ER_LOCK_ABORTED";i[1690]="ER_DATA_OUT_OF_RANGE";i[1691]="ER_WRONG_SPVAR_TYPE_IN_LIMIT";i[1692]="ER_BINLOG_UNSAFE_MULTIPLE_ENGINES_AND_SELF_LOGGING_ENGINE";i[1693]="ER_BINLOG_UNSAFE_MIXED_STATEMENT";i[1694]="ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_SQL_LOG_BIN";i[1695]="ER_STORED_FUNCTION_PREVENTS_SWITCH_SQL_LOG_BIN";i[1696]="ER_FAILED_READ_FROM_PAR_FILE";i[1697]="ER_VALUES_IS_NOT_INT_TYPE_ERROR";i[1698]="ER_ACCESS_DENIED_NO_PASSWORD_ERROR";i[1699]="ER_SET_PASSWORD_AUTH_PLUGIN";i[1700]="ER_GRANT_PLUGIN_USER_EXISTS";i[1701]="ER_TRUNCATE_ILLEGAL_FK";i[1702]="ER_PLUGIN_IS_PERMANENT";i[1703]="ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE_MIN";i[1704]="ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE_MAX";i[1705]="ER_STMT_CACHE_FULL";i[1706]="ER_MULTI_UPDATE_KEY_CONFLICT";i[1707]="ER_TABLE_NEEDS_REBUILD";i[1708]="WARN_OPTION_BELOW_LIMIT";i[1709]="ER_INDEX_COLUMN_TOO_LONG";i[1710]="ER_ERROR_IN_TRIGGER_BODY";i[1711]="ER_ERROR_IN_UNKNOWN_TRIGGER_BODY";i[1712]="ER_INDEX_CORRUPT";i[1713]="ER_UNDO_RECORD_TOO_BIG";i[1714]="ER_BINLOG_UNSAFE_INSERT_IGNORE_SELECT";i[1715]="ER_BINLOG_UNSAFE_INSERT_SELECT_UPDATE";i[1716]="ER_BINLOG_UNSAFE_REPLACE_SELECT";i[1717]="ER_BINLOG_UNSAFE_CREATE_IGNORE_SELECT";i[1718]="ER_BINLOG_UNSAFE_CREATE_REPLACE_SELECT";i[1719]="ER_BINLOG_UNSAFE_UPDATE_IGNORE";i[1720]="ER_UNUSED_15";i[1721]="ER_UNUSED_16";i[1722]="ER_BINLOG_UNSAFE_WRITE_AUTOINC_SELECT";i[1723]="ER_BINLOG_UNSAFE_CREATE_SELECT_AUTOINC";i[1724]="ER_BINLOG_UNSAFE_INSERT_TWO_KEYS";i[1725]="ER_UNUSED_28";i[1726]="ER_VERS_NOT_ALLOWED";i[1727]="ER_BINLOG_UNSAFE_AUTOINC_NOT_FIRST";i[1728]="ER_CANNOT_LOAD_FROM_TABLE_V2";i[1729]="ER_MASTER_DELAY_VALUE_OUT_OF_RANGE";i[1730]="ER_ONLY_FD_AND_RBR_EVENTS_ALLOWED_IN_BINLOG_STATEMENT";i[1731]="ER_PARTITION_EXCHANGE_DIFFERENT_OPTION";i[1732]="ER_PARTITION_EXCHANGE_PART_TABLE";i[1733]="ER_PARTITION_EXCHANGE_TEMP_TABLE";i[1734]="ER_PARTITION_INSTEAD_OF_SUBPARTITION";i[1735]="ER_UNKNOWN_PARTITION";i[1736]="ER_TABLES_DIFFERENT_METADATA";i[1737]="ER_ROW_DOES_NOT_MATCH_PARTITION";i[1738]="ER_BINLOG_CACHE_SIZE_GREATER_THAN_MAX";i[1739]="ER_WARN_INDEX_NOT_APPLICABLE";i[1740]="ER_PARTITION_EXCHANGE_FOREIGN_KEY";i[1741]="ER_NO_SUCH_KEY_VALUE";i[1742]="ER_VALUE_TOO_LONG";i[1743]="ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE";i[1744]="ER_BINLOG_READ_EVENT_CHECKSUM_FAILURE";i[1745]="ER_BINLOG_STMT_CACHE_SIZE_GREATER_THAN_MAX";i[1746]="ER_CANT_UPDATE_TABLE_IN_CREATE_TABLE_SELECT";i[1747]="ER_PARTITION_CLAUSE_ON_NONPARTITIONED";i[1748]="ER_ROW_DOES_NOT_MATCH_GIVEN_PARTITION_SET";i[1749]="ER_UNUSED_5";i[1750]="ER_CHANGE_RPL_INFO_REPOSITORY_FAILURE";i[1751]="ER_WARNING_NOT_COMPLETE_ROLLBACK_WITH_CREATED_TEMP_TABLE";i[1752]="ER_WARNING_NOT_COMPLETE_ROLLBACK_WITH_DROPPED_TEMP_TABLE";i[1753]="ER_MTS_FEATURE_IS_NOT_SUPPORTED";i[1754]="ER_MTS_UPDATED_DBS_GREATER_MAX";i[1755]="ER_MTS_CANT_PARALLEL";i[1756]="ER_MTS_INCONSISTENT_DATA";i[1757]="ER_FULLTEXT_NOT_SUPPORTED_WITH_PARTITIONING";i[1758]="ER_DA_INVALID_CONDITION_NUMBER";i[1759]="ER_INSECURE_PLAIN_TEXT";i[1760]="ER_INSECURE_CHANGE_MASTER";i[1761]="ER_FOREIGN_DUPLICATE_KEY_WITH_CHILD_INFO";i[1762]="ER_FOREIGN_DUPLICATE_KEY_WITHOUT_CHILD_INFO";i[1763]="ER_SQLTHREAD_WITH_SECURE_SLAVE";i[1764]="ER_TABLE_HAS_NO_FT";i[1765]="ER_VARIABLE_NOT_SETTABLE_IN_SF_OR_TRIGGER";i[1766]="ER_VARIABLE_NOT_SETTABLE_IN_TRANSACTION";i[1767]="ER_GTID_NEXT_IS_NOT_IN_GTID_NEXT_LIST";i[1768]="ER_CANT_CHANGE_GTID_NEXT_IN_TRANSACTION_WHEN_GTID_NEXT_LIST_IS_NULL";i[1769]="ER_SET_STATEMENT_CANNOT_INVOKE_FUNCTION";i[1770]="ER_GTID_NEXT_CANT_BE_AUTOMATIC_IF_GTID_NEXT_LIST_IS_NON_NULL";i[1771]="ER_SKIPPING_LOGGED_TRANSACTION";i[1772]="ER_MALFORMED_GTID_SET_SPECIFICATION";i[1773]="ER_MALFORMED_GTID_SET_ENCODING";i[1774]="ER_MALFORMED_GTID_SPECIFICATION";i[1775]="ER_GNO_EXHAUSTED";i[1776]="ER_BAD_SLAVE_AUTO_POSITION";i[1777]="ER_AUTO_POSITION_REQUIRES_GTID_MODE_ON";i[1778]="ER_CANT_DO_IMPLICIT_COMMIT_IN_TRX_WHEN_GTID_NEXT_IS_SET";i[1779]="ER_GTID_MODE_2_OR_3_REQUIRES_ENFORCE_GTID_CONSISTENCY_ON";i[1780]="ER_GTID_MODE_REQUIRES_BINLOG";i[1781]="ER_CANT_SET_GTID_NEXT_TO_GTID_WHEN_GTID_MODE_IS_OFF";i[1782]="ER_CANT_SET_GTID_NEXT_TO_ANONYMOUS_WHEN_GTID_MODE_IS_ON";i[1783]="ER_CANT_SET_GTID_NEXT_LIST_TO_NON_NULL_WHEN_GTID_MODE_IS_OFF";i[1784]="ER_FOUND_GTID_EVENT_WHEN_GTID_MODE_IS_OFF";i[1785]="ER_GTID_UNSAFE_NON_TRANSACTIONAL_TABLE";i[1786]="ER_GTID_UNSAFE_CREATE_SELECT";i[1787]="ER_GTID_UNSAFE_CREATE_DROP_TEMPORARY_TABLE_IN_TRANSACTION";i[1788]="ER_GTID_MODE_CAN_ONLY_CHANGE_ONE_STEP_AT_A_TIME";i[1789]="ER_MASTER_HAS_PURGED_REQUIRED_GTIDS";i[1790]="ER_CANT_SET_GTID_NEXT_WHEN_OWNING_GTID";i[1791]="ER_UNKNOWN_EXPLAIN_FORMAT";i[1792]="ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION";i[1793]="ER_TOO_LONG_TABLE_PARTITION_COMMENT";i[1794]="ER_SLAVE_CONFIGURATION";i[1795]="ER_INNODB_FT_LIMIT";i[1796]="ER_NO_INDEX_ON_TEMPORARY";i[1797]="ER_INNODB_FT_WRONG_DOCID_COLUMN";i[1798]="ER_INNODB_FT_WRONG_DOCID_INDEX";i[1799]="ER_INNODB_ONLINE_LOG_TOO_BIG";i[1800]="ER_UNKNOWN_ALTER_ALGORITHM";i[1801]="ER_UNKNOWN_ALTER_LOCK";i[1802]="ER_MTS_CHANGE_MASTER_CANT_RUN_WITH_GAPS";i[1803]="ER_MTS_RECOVERY_FAILURE";i[1804]="ER_MTS_RESET_WORKERS";i[1805]="ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2";i[1806]="ER_SLAVE_SILENT_RETRY_TRANSACTION";i[1807]="ER_UNUSED_22";i[1808]="ER_TABLE_SCHEMA_MISMATCH";i[1809]="ER_TABLE_IN_SYSTEM_TABLESPACE";i[1810]="ER_IO_READ_ERROR";i[1811]="ER_IO_WRITE_ERROR";i[1812]="ER_TABLESPACE_MISSING";i[1813]="ER_TABLESPACE_EXISTS";i[1814]="ER_TABLESPACE_DISCARDED";i[1815]="ER_INTERNAL_ERROR";i[1816]="ER_INNODB_IMPORT_ERROR";i[1817]="ER_INNODB_INDEX_CORRUPT";i[1818]="ER_INVALID_YEAR_COLUMN_LENGTH";i[1819]="ER_NOT_VALID_PASSWORD";i[1820]="ER_MUST_CHANGE_PASSWORD";i[1821]="ER_FK_NO_INDEX_CHILD";i[1822]="ER_FK_NO_INDEX_PARENT";i[1823]="ER_FK_FAIL_ADD_SYSTEM";i[1824]="ER_FK_CANNOT_OPEN_PARENT";i[1825]="ER_FK_INCORRECT_OPTION";i[1826]="ER_DUP_CONSTRAINT_NAME";i[1827]="ER_PASSWORD_FORMAT";i[1828]="ER_FK_COLUMN_CANNOT_DROP";i[1829]="ER_FK_COLUMN_CANNOT_DROP_CHILD";i[1830]="ER_FK_COLUMN_NOT_NULL";i[1831]="ER_DUP_INDEX";i[1832]="ER_FK_COLUMN_CANNOT_CHANGE";i[1833]="ER_FK_COLUMN_CANNOT_CHANGE_CHILD";i[1834]="ER_FK_CANNOT_DELETE_PARENT";i[1835]="ER_MALFORMED_PACKET";i[1836]="ER_READ_ONLY_MODE";i[1837]="ER_GTID_NEXT_TYPE_UNDEFINED_GROUP";i[1838]="ER_VARIABLE_NOT_SETTABLE_IN_SP";i[1839]="ER_CANT_SET_GTID_PURGED_WHEN_GTID_MODE_IS_OFF";i[1840]="ER_CANT_SET_GTID_PURGED_WHEN_GTID_EXECUTED_IS_NOT_EMPTY";i[1841]="ER_CANT_SET_GTID_PURGED_WHEN_OWNED_GTIDS_IS_NOT_EMPTY";i[1842]="ER_GTID_PURGED_WAS_CHANGED";i[1843]="ER_GTID_EXECUTED_WAS_CHANGED";i[1844]="ER_BINLOG_STMT_MODE_AND_NO_REPL_TABLES";i[1845]="ER_ALTER_OPERATION_NOT_SUPPORTED";i[1846]="ER_ALTER_OPERATION_NOT_SUPPORTED_REASON";i[1847]="ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_COPY";i[1848]="ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_PARTITION";i[1849]="ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_FK_RENAME";i[1850]="ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_COLUMN_TYPE";i[1851]="ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_FK_CHECK";i[1852]="ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_IGNORE";i[1853]="ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_NOPK";i[1854]="ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_AUTOINC";i[1855]="ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_HIDDEN_FTS";i[1856]="ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_CHANGE_FTS";i[1857]="ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_FTS";i[1858]="ER_SQL_SLAVE_SKIP_COUNTER_NOT_SETTABLE_IN_GTID_MODE";i[1859]="ER_DUP_UNKNOWN_IN_INDEX";i[1860]="ER_IDENT_CAUSES_TOO_LONG_PATH";i[1861]="ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_NOT_NULL";i[1862]="ER_MUST_CHANGE_PASSWORD_LOGIN";i[1863]="ER_ROW_IN_WRONG_PARTITION";i[1864]="ER_MTS_EVENT_BIGGER_PENDING_JOBS_SIZE_MAX";i[1865]="ER_INNODB_NO_FT_USES_PARSER";i[1866]="ER_BINLOG_LOGICAL_CORRUPTION";i[1867]="ER_WARN_PURGE_LOG_IN_USE";i[1868]="ER_WARN_PURGE_LOG_IS_ACTIVE";i[1869]="ER_AUTO_INCREMENT_CONFLICT";i[1870]="WARN_ON_BLOCKHOLE_IN_RBR";i[1871]="ER_SLAVE_MI_INIT_REPOSITORY";i[1872]="ER_SLAVE_RLI_INIT_REPOSITORY";i[1873]="ER_ACCESS_DENIED_CHANGE_USER_ERROR";i[1874]="ER_INNODB_READ_ONLY";i[1875]="ER_STOP_SLAVE_SQL_THREAD_TIMEOUT";i[1876]="ER_STOP_SLAVE_IO_THREAD_TIMEOUT";i[1877]="ER_TABLE_CORRUPT";i[1878]="ER_TEMP_FILE_WRITE_FAILURE";i[1879]="ER_INNODB_FT_AUX_NOT_HEX_ID";i[1880]="ER_LAST_MYSQL_ERROR_MESSAGE";i[1900]="ER_UNUSED_18";i[1901]="ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED";i[1902]="ER_UNUSED_19";i[1903]="ER_PRIMARY_KEY_BASED_ON_GENERATED_COLUMN";i[1904]="ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN";i[1905]="ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN";i[1906]="ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN";i[1907]="ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN";i[1908]="ER_UNUSED_20";i[1909]="ER_UNUSED_21";i[1910]="ER_UNSUPPORTED_ENGINE_FOR_GENERATED_COLUMNS";i[1911]="ER_UNKNOWN_OPTION";i[1912]="ER_BAD_OPTION_VALUE";i[1913]="ER_UNUSED_6";i[1914]="ER_UNUSED_7";i[1915]="ER_UNUSED_8";i[1916]="ER_DATA_OVERFLOW";i[1917]="ER_DATA_TRUNCATED";i[1918]="ER_BAD_DATA";i[1919]="ER_DYN_COL_WRONG_FORMAT";i[1920]="ER_DYN_COL_IMPLEMENTATION_LIMIT";i[1921]="ER_DYN_COL_DATA";i[1922]="ER_DYN_COL_WRONG_CHARSET";i[1923]="ER_ILLEGAL_SUBQUERY_OPTIMIZER_SWITCHES";i[1924]="ER_QUERY_CACHE_IS_DISABLED";i[1925]="ER_QUERY_CACHE_IS_GLOBALY_DISABLED";i[1926]="ER_VIEW_ORDERBY_IGNORED";i[1927]="ER_CONNECTION_KILLED";i[1928]="ER_UNUSED_12";i[1929]="ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_SKIP_REPLICATION";i[1930]="ER_STORED_FUNCTION_PREVENTS_SWITCH_SKIP_REPLICATION";i[1931]="ER_QUERY_RESULT_INCOMPLETE";i[1932]="ER_NO_SUCH_TABLE_IN_ENGINE";i[1933]="ER_TARGET_NOT_EXPLAINABLE";i[1934]="ER_CONNECTION_ALREADY_EXISTS";i[1935]="ER_MASTER_LOG_PREFIX";i[1936]="ER_CANT_START_STOP_SLAVE";i[1937]="ER_SLAVE_STARTED";i[1938]="ER_SLAVE_STOPPED";i[1939]="ER_SQL_DISCOVER_ERROR";i[1940]="ER_FAILED_GTID_STATE_INIT";i[1941]="ER_INCORRECT_GTID_STATE";i[1942]="ER_CANNOT_UPDATE_GTID_STATE";i[1943]="ER_DUPLICATE_GTID_DOMAIN";i[1944]="ER_GTID_OPEN_TABLE_FAILED";i[1945]="ER_GTID_POSITION_NOT_FOUND_IN_BINLOG";i[1946]="ER_CANNOT_LOAD_SLAVE_GTID_STATE";i[1947]="ER_MASTER_GTID_POS_CONFLICTS_WITH_BINLOG";i[1948]="ER_MASTER_GTID_POS_MISSING_DOMAIN";i[1949]="ER_UNTIL_REQUIRES_USING_GTID";i[1950]="ER_GTID_STRICT_OUT_OF_ORDER";i[1951]="ER_GTID_START_FROM_BINLOG_HOLE";i[1952]="ER_SLAVE_UNEXPECTED_MASTER_SWITCH";i[1953]="ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_GTID_DOMAIN_ID_SEQ_NO";i[1954]="ER_STORED_FUNCTION_PREVENTS_SWITCH_GTID_DOMAIN_ID_SEQ_NO";i[1955]="ER_GTID_POSITION_NOT_FOUND_IN_BINLOG2";i[1956]="ER_BINLOG_MUST_BE_EMPTY";i[1957]="ER_NO_SUCH_QUERY";i[1958]="ER_BAD_BASE64_DATA";i[1959]="ER_INVALID_ROLE";i[1960]="ER_INVALID_CURRENT_USER";i[1961]="ER_CANNOT_GRANT_ROLE";i[1962]="ER_CANNOT_REVOKE_ROLE";i[1963]="ER_CHANGE_SLAVE_PARALLEL_THREADS_ACTIVE";i[1964]="ER_PRIOR_COMMIT_FAILED";i[1965]="ER_IT_IS_A_VIEW";i[1966]="ER_SLAVE_SKIP_NOT_IN_GTID";i[1967]="ER_TABLE_DEFINITION_TOO_BIG";i[1968]="ER_PLUGIN_INSTALLED";i[1969]="ER_STATEMENT_TIMEOUT";i[1970]="ER_SUBQUERIES_NOT_SUPPORTED";i[1971]="ER_SET_STATEMENT_NOT_SUPPORTED";i[1972]="ER_UNUSED_9";i[1973]="ER_USER_CREATE_EXISTS";i[1974]="ER_USER_DROP_EXISTS";i[1975]="ER_ROLE_CREATE_EXISTS";i[1976]="ER_ROLE_DROP_EXISTS";i[1977]="ER_CANNOT_CONVERT_CHARACTER";i[1978]="ER_INVALID_DEFAULT_VALUE_FOR_FIELD";i[1979]="ER_KILL_QUERY_DENIED_ERROR";i[1980]="ER_NO_EIS_FOR_FIELD";i[1981]="ER_WARN_AGGFUNC_DEPENDENCE";i[1982]="WARN_INNODB_PARTITION_OPTION_IGNORED";i[3e3]="ER_FILE_CORRUPT";i[3001]="ER_ERROR_ON_MASTER";i[3002]="ER_INCONSISTENT_ERROR";i[3003]="ER_STORAGE_ENGINE_NOT_LOADED";i[3004]="ER_GET_STACKED_DA_WITHOUT_ACTIVE_HANDLER";i[3005]="ER_WARN_LEGACY_SYNTAX_CONVERTED";i[3006]="ER_BINLOG_UNSAFE_FULLTEXT_PLUGIN";i[3007]="ER_CANNOT_DISCARD_TEMPORARY_TABLE";i[3008]="ER_FK_DEPTH_EXCEEDED";i[3009]="ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE_V2";i[3010]="ER_WARN_TRIGGER_DOESNT_HAVE_CREATED";i[3011]="ER_REFERENCED_TRG_DOES_NOT_EXIST_MYSQL";i[3012]="ER_EXPLAIN_NOT_SUPPORTED";i[3013]="ER_INVALID_FIELD_SIZE";i[3014]="ER_MISSING_HA_CREATE_OPTION";i[3015]="ER_ENGINE_OUT_OF_MEMORY";i[3016]="ER_PASSWORD_EXPIRE_ANONYMOUS_USER";i[3017]="ER_SLAVE_SQL_THREAD_MUST_STOP";i[3018]="ER_NO_FT_MATERIALIZED_SUBQUERY";i[3019]="ER_INNODB_UNDO_LOG_FULL";i[3020]="ER_INVALID_ARGUMENT_FOR_LOGARITHM";i[3021]="ER_SLAVE_CHANNEL_IO_THREAD_MUST_STOP";i[3022]="ER_WARN_OPEN_TEMP_TABLES_MUST_BE_ZERO";i[3023]="ER_WARN_ONLY_MASTER_LOG_FILE_NO_POS";i[3024]="ER_UNUSED_1";i[3025]="ER_NON_RO_SELECT_DISABLE_TIMER";i[3026]="ER_DUP_LIST_ENTRY";i[3027]="ER_SQL_MODE_NO_EFFECT";i[3028]="ER_AGGREGATE_ORDER_FOR_UNION";i[3029]="ER_AGGREGATE_ORDER_NON_AGG_QUERY";i[3030]="ER_SLAVE_WORKER_STOPPED_PREVIOUS_THD_ERROR";i[3031]="ER_DONT_SUPPORT_SLAVE_PRESERVE_COMMIT_ORDER";i[3032]="ER_SERVER_OFFLINE_MODE";i[3033]="ER_GIS_DIFFERENT_SRIDS";i[3034]="ER_GIS_UNSUPPORTED_ARGUMENT";i[3035]="ER_GIS_UNKNOWN_ERROR";i[3036]="ER_GIS_UNKNOWN_EXCEPTION";i[3037]="ER_GIS_INVALID_DATA";i[3038]="ER_BOOST_GEOMETRY_EMPTY_INPUT_EXCEPTION";i[3039]="ER_BOOST_GEOMETRY_CENTROID_EXCEPTION";i[3040]="ER_BOOST_GEOMETRY_OVERLAY_INVALID_INPUT_EXCEPTION";i[3041]="ER_BOOST_GEOMETRY_TURN_INFO_EXCEPTION";i[3042]="ER_BOOST_GEOMETRY_SELF_INTERSECTION_POINT_EXCEPTION";i[3043]="ER_BOOST_GEOMETRY_UNKNOWN_EXCEPTION";i[3044]="ER_STD_BAD_ALLOC_ERROR";i[3045]="ER_STD_DOMAIN_ERROR";i[3046]="ER_STD_LENGTH_ERROR";i[3047]="ER_STD_INVALID_ARGUMENT";i[3048]="ER_STD_OUT_OF_RANGE_ERROR";i[3049]="ER_STD_OVERFLOW_ERROR";i[3050]="ER_STD_RANGE_ERROR";i[3051]="ER_STD_UNDERFLOW_ERROR";i[3052]="ER_STD_LOGIC_ERROR";i[3053]="ER_STD_RUNTIME_ERROR";i[3054]="ER_STD_UNKNOWN_EXCEPTION";i[3055]="ER_GIS_DATA_WRONG_ENDIANESS";i[3056]="ER_CHANGE_MASTER_PASSWORD_LENGTH";i[3057]="ER_USER_LOCK_WRONG_NAME";i[3058]="ER_USER_LOCK_DEADLOCK";i[3059]="ER_REPLACE_INACCESSIBLE_ROWS";i[3060]="ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_GIS";i[3061]="ER_MYSQL_3061";i[3062]="ER_MYSQL_3062";i[3063]="ER_MYSQL_3063";i[3064]="ER_MYSQL_3064";i[3065]="ER_MYSQL_3065";i[3066]="ER_MYSQL_3066";i[3067]="ER_MYSQL_3067";i[3068]="ER_MYSQL_3068";i[3069]="ER_MYSQL_3069";i[3070]="ER_MYSQL_3070";i[3071]="ER_MYSQL_3071";i[3072]="ER_MYSQL_3072";i[3073]="ER_MYSQL_3073";i[3074]="ER_MYSQL_3074";i[3075]="ER_MYSQL_3075";i[3076]="ER_MYSQL_3076";i[3077]="ER_MYSQL_3077";i[3078]="ER_MYSQL_3078";i[3079]="ER_MYSQL_3079";i[3080]="ER_MYSQL_3080";i[3081]="ER_MYSQL_3081";i[3082]="ER_MYSQL_3082";i[3083]="ER_MYSQL_3083";i[3084]="ER_MYSQL_3084";i[3085]="ER_MYSQL_3085";i[3086]="ER_MYSQL_3086";i[3087]="ER_MYSQL_3087";i[3088]="ER_MYSQL_3088";i[3089]="ER_MYSQL_3089";i[3090]="ER_MYSQL_3090";i[3091]="ER_MYSQL_3091";i[3092]="ER_MYSQL_3092";i[3093]="ER_MYSQL_3093";i[3094]="ER_MYSQL_3094";i[3095]="ER_MYSQL_3095";i[3096]="ER_MYSQL_3096";i[3097]="ER_MYSQL_3097";i[3098]="ER_MYSQL_3098";i[3099]="ER_MYSQL_3099";i[3100]="ER_MYSQL_3100";i[3101]="ER_MYSQL_3101";i[3102]="ER_MYSQL_3102";i[3103]="ER_MYSQL_3103";i[3104]="ER_MYSQL_3104";i[3105]="ER_MYSQL_3105";i[3106]="ER_MYSQL_3106";i[3107]="ER_MYSQL_3107";i[3108]="ER_MYSQL_3108";i[3109]="ER_MYSQL_3109";i[3110]="ER_MYSQL_3110";i[3111]="ER_MYSQL_3111";i[3112]="ER_MYSQL_3112";i[3113]="ER_MYSQL_3113";i[3114]="ER_MYSQL_3114";i[3115]="ER_MYSQL_3115";i[3116]="ER_MYSQL_3116";i[3117]="ER_MYSQL_3117";i[3118]="ER_MYSQL_3118";i[3119]="ER_MYSQL_3119";i[3120]="ER_MYSQL_3120";i[3121]="ER_MYSQL_3121";i[3122]="ER_MYSQL_3122";i[3123]="ER_MYSQL_3123";i[3124]="ER_MYSQL_3124";i[3125]="ER_MYSQL_3125";i[3126]="ER_MYSQL_3126";i[3127]="ER_MYSQL_3127";i[3128]="ER_MYSQL_3128";i[3129]="ER_MYSQL_3129";i[3130]="ER_MYSQL_3130";i[3131]="ER_MYSQL_3131";i[3132]="ER_MYSQL_3132";i[3133]="ER_MYSQL_3133";i[3134]="ER_MYSQL_3134";i[3135]="ER_MYSQL_3135";i[3136]="ER_MYSQL_3136";i[3137]="ER_MYSQL_3137";i[3138]="ER_MYSQL_3138";i[3139]="ER_MYSQL_3139";i[3140]="ER_MYSQL_3140";i[3141]="ER_MYSQL_3141";i[3142]="ER_MYSQL_3142";i[3143]="ER_MYSQL_3143";i[3144]="ER_MYSQL_3144";i[3145]="ER_MYSQL_3145";i[3146]="ER_MYSQL_3146";i[3147]="ER_MYSQL_3147";i[3148]="ER_MYSQL_3148";i[3149]="ER_MYSQL_3149";i[3150]="ER_MYSQL_3150";i[3151]="ER_MYSQL_3151";i[3152]="ER_MYSQL_3152";i[3153]="ER_MYSQL_3153";i[3154]="ER_MYSQL_3154";i[3155]="ER_MYSQL_3155";i[3156]="ER_MYSQL_3156";i[3157]="ER_MYSQL_3157";i[3158]="ER_MYSQL_3158";i[3159]="ER_SECURE_TRANSPORT_REQUIRED";i[4e3]="ER_UNUSED_26";i[4001]="ER_UNUSED_27";i[4002]="ER_WITH_COL_WRONG_LIST";i[4003]="ER_TOO_MANY_DEFINITIONS_IN_WITH_CLAUSE";i[4004]="ER_DUP_QUERY_NAME";i[4005]="ER_RECURSIVE_WITHOUT_ANCHORS";i[4006]="ER_UNACCEPTABLE_MUTUAL_RECURSION";i[4007]="ER_REF_TO_RECURSIVE_WITH_TABLE_IN_DERIVED";i[4008]="ER_NOT_STANDARD_COMPLIANT_RECURSIVE";i[4009]="ER_WRONG_WINDOW_SPEC_NAME";i[4010]="ER_DUP_WINDOW_NAME";i[4011]="ER_PARTITION_LIST_IN_REFERENCING_WINDOW_SPEC";i[4012]="ER_ORDER_LIST_IN_REFERENCING_WINDOW_SPEC";i[4013]="ER_WINDOW_FRAME_IN_REFERENCED_WINDOW_SPEC";i[4014]="ER_BAD_COMBINATION_OF_WINDOW_FRAME_BOUND_SPECS";i[4015]="ER_WRONG_PLACEMENT_OF_WINDOW_FUNCTION";i[4016]="ER_WINDOW_FUNCTION_IN_WINDOW_SPEC";i[4017]="ER_NOT_ALLOWED_WINDOW_FRAME";i[4018]="ER_NO_ORDER_LIST_IN_WINDOW_SPEC";i[4019]="ER_RANGE_FRAME_NEEDS_SIMPLE_ORDERBY";i[4020]="ER_WRONG_TYPE_FOR_ROWS_FRAME";i[4021]="ER_WRONG_TYPE_FOR_RANGE_FRAME";i[4022]="ER_FRAME_EXCLUSION_NOT_SUPPORTED";i[4023]="ER_WINDOW_FUNCTION_DONT_HAVE_FRAME";i[4024]="ER_INVALID_NTILE_ARGUMENT";i[4025]="ER_CONSTRAINT_FAILED";i[4026]="ER_EXPRESSION_IS_TOO_BIG";i[4027]="ER_ERROR_EVALUATING_EXPRESSION";i[4028]="ER_CALCULATING_DEFAULT_VALUE";i[4029]="ER_EXPRESSION_REFERS_TO_UNINIT_FIELD";i[4030]="ER_PARTITION_DEFAULT_ERROR";i[4031]="ER_REFERENCED_TRG_DOES_NOT_EXIST";i[4032]="ER_INVALID_DEFAULT_PARAM";i[4033]="ER_BINLOG_NON_SUPPORTED_BULK";i[4034]="ER_BINLOG_UNCOMPRESS_ERROR";i[4035]="ER_JSON_BAD_CHR";i[4036]="ER_JSON_NOT_JSON_CHR";i[4037]="ER_JSON_EOS";i[4038]="ER_JSON_SYNTAX";i[4039]="ER_JSON_ESCAPING";i[4040]="ER_JSON_DEPTH";i[4041]="ER_JSON_PATH_EOS";i[4042]="ER_JSON_PATH_SYNTAX";i[4043]="ER_JSON_PATH_DEPTH";i[4044]="ER_JSON_PATH_NO_WILDCARD";i[4045]="ER_JSON_PATH_ARRAY";i[4046]="ER_JSON_ONE_OR_ALL";i[4047]="ER_UNSUPPORTED_COMPRESSED_TABLE";i[4048]="ER_GEOJSON_INCORRECT";i[4049]="ER_GEOJSON_TOO_FEW_POINTS";i[4050]="ER_GEOJSON_NOT_CLOSED";i[4051]="ER_JSON_PATH_EMPTY";i[4052]="ER_SLAVE_SAME_ID";i[4053]="ER_FLASHBACK_NOT_SUPPORTED";i[4054]="ER_KEYS_OUT_OF_ORDER";i[4055]="ER_OVERLAPPING_KEYS";i[4056]="ER_REQUIRE_ROW_BINLOG_FORMAT";i[4057]="ER_ISOLATION_MODE_NOT_SUPPORTED";i[4058]="ER_ON_DUPLICATE_DISABLED";i[4059]="ER_UPDATES_WITH_CONSISTENT_SNAPSHOT";i[4060]="ER_ROLLBACK_ONLY";i[4061]="ER_ROLLBACK_TO_SAVEPOINT";i[4062]="ER_ISOLATION_LEVEL_WITH_CONSISTENT_SNAPSHOT";i[4063]="ER_UNSUPPORTED_COLLATION";i[4064]="ER_METADATA_INCONSISTENCY";i[4065]="ER_CF_DIFFERENT";i[4066]="ER_RDB_TTL_DURATION_FORMAT";i[4067]="ER_RDB_STATUS_GENERAL";i[4068]="ER_RDB_STATUS_MSG";i[4069]="ER_RDB_TTL_UNSUPPORTED";i[4070]="ER_RDB_TTL_COL_FORMAT";i[4071]="ER_PER_INDEX_CF_DEPRECATED";i[4072]="ER_KEY_CREATE_DURING_ALTER";i[4073]="ER_SK_POPULATE_DURING_ALTER";i[4074]="ER_SUM_FUNC_WITH_WINDOW_FUNC_AS_ARG";i[4075]="ER_NET_OK_PACKET_TOO_LARGE";i[4076]="ER_GEOJSON_EMPTY_COORDINATES";i[4077]="ER_MYROCKS_CANT_NOPAD_COLLATION";i[4078]="ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION";i[4079]="ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION";i[4080]="ER_WRONG_PARAMCOUNT_TO_CURSOR";i[4081]="ER_UNKNOWN_STRUCTURED_VARIABLE";i[4082]="ER_ROW_VARIABLE_DOES_NOT_HAVE_FIELD";i[4083]="ER_END_IDENTIFIER_DOES_NOT_MATCH";i[4084]="ER_SEQUENCE_RUN_OUT";i[4085]="ER_SEQUENCE_INVALID_DATA";i[4086]="ER_SEQUENCE_INVALID_TABLE_STRUCTURE";i[4087]="ER_SEQUENCE_ACCESS_ERROR";i[4088]="ER_SEQUENCE_BINLOG_FORMAT";i[4089]="ER_NOT_SEQUENCE";i[4090]="ER_NOT_SEQUENCE2";i[4091]="ER_UNKNOWN_SEQUENCES";i[4092]="ER_UNKNOWN_VIEW";i[4093]="ER_WRONG_INSERT_INTO_SEQUENCE";i[4094]="ER_SP_STACK_TRACE";i[4095]="ER_PACKAGE_ROUTINE_IN_SPEC_NOT_DEFINED_IN_BODY";i[4096]="ER_PACKAGE_ROUTINE_FORWARD_DECLARATION_NOT_DEFINED";i[4097]="ER_COMPRESSED_COLUMN_USED_AS_KEY";i[4098]="ER_UNKNOWN_COMPRESSION_METHOD";i[4099]="ER_WRONG_NUMBER_OF_VALUES_IN_TVC";i[4100]="ER_FIELD_REFERENCE_IN_TVC";i[4101]="ER_WRONG_TYPE_FOR_PERCENTILE_FUNC";i[4102]="ER_ARGUMENT_NOT_CONSTANT";i[4103]="ER_ARGUMENT_OUT_OF_RANGE";i[4104]="ER_WRONG_TYPE_OF_ARGUMENT";i[4105]="ER_NOT_AGGREGATE_FUNCTION";i[4106]="ER_INVALID_AGGREGATE_FUNCTION";i[4107]="ER_INVALID_VALUE_TO_LIMIT";i[4108]="ER_INVISIBLE_NOT_NULL_WITHOUT_DEFAULT";i[4109]="ER_UPDATE_INFO_WITH_SYSTEM_VERSIONING";i[4110]="ER_VERS_FIELD_WRONG_TYPE";i[4111]="ER_VERS_ENGINE_UNSUPPORTED";i[4112]="ER_WRONG_VERSIONING_RANGE";i[4113]="ER_PARTITION_WRONG_TYPE";i[4114]="WARN_VERS_PART_FULL";i[4115]="WARN_VERS_PARAMETERS";i[4116]="ER_VERS_DROP_PARTITION_INTERVAL";i[4117]="ER_UNUSED_25";i[4118]="WARN_VERS_PART_NON_HISTORICAL";i[4119]="ER_VERS_ALTER_NOT_ALLOWED";i[4120]="ER_VERS_ALTER_ENGINE_PROHIBITED";i[4121]="ER_VERS_RANGE_PROHIBITED";i[4122]="ER_CONFLICTING_FOR_SYSTEM_TIME";i[4123]="ER_VERS_TABLE_MUST_HAVE_COLUMNS";i[4124]="ER_VERS_NOT_VERSIONED";i[4125]="ER_MISSING";i[4126]="ER_VERS_PERIOD_COLUMNS";i[4127]="ER_PART_WRONG_VALUE";i[4128]="ER_VERS_WRONG_PARTS";i[4129]="ER_VERS_NO_TRX_ID";i[4130]="ER_VERS_ALTER_SYSTEM_FIELD";i[4131]="ER_DROP_VERSIONING_SYSTEM_TIME_PARTITION";i[4132]="ER_VERS_DB_NOT_SUPPORTED";i[4133]="ER_VERS_TRT_IS_DISABLED";i[4134]="ER_VERS_DUPLICATE_ROW_START_END";i[4135]="ER_VERS_ALREADY_VERSIONED";i[4136]="ER_UNUSED_24";i[4137]="ER_VERS_NOT_SUPPORTED";i[4138]="ER_VERS_TRX_PART_HISTORIC_ROW_NOT_SUPPORTED";i[4139]="ER_INDEX_FILE_FULL";i[4140]="ER_UPDATED_COLUMN_ONLY_ONCE";i[4141]="ER_EMPTY_ROW_IN_TVC";i[4142]="ER_VERS_QUERY_IN_PARTITION";i[4143]="ER_KEY_DOESNT_SUPPORT";i[4144]="ER_ALTER_OPERATION_TABLE_OPTIONS_NEED_REBUILD";i[4145]="ER_BACKUP_LOCK_IS_ACTIVE";i[4146]="ER_BACKUP_NOT_RUNNING";i[4147]="ER_BACKUP_WRONG_STAGE";i[4148]="ER_BACKUP_STAGE_FAILED";i[4149]="ER_BACKUP_UNKNOWN_STAGE";i[4150]="ER_USER_IS_BLOCKED";i[4151]="ER_ACCOUNT_HAS_BEEN_LOCKED";i[4152]="ER_PERIOD_TEMPORARY_NOT_ALLOWED";i[4153]="ER_PERIOD_TYPES_MISMATCH";i[4154]="ER_MORE_THAN_ONE_PERIOD";i[4155]="ER_PERIOD_FIELD_WRONG_ATTRIBUTES";i[4156]="ER_PERIOD_NOT_FOUND";i[4157]="ER_PERIOD_COLUMNS_UPDATED";i[4158]="ER_PERIOD_CONSTRAINT_DROP";i[4159]="ER_TOO_LONG_KEYPART";i[4160]="ER_TOO_LONG_DATABASE_COMMENT";i[4161]="ER_UNKNOWN_DATA_TYPE";i[4162]="ER_UNKNOWN_OPERATOR";i[4163]="ER_SP_DUP_DECL";i[4164]="ER_PART_STARTS_BEYOND_INTERVAL";i[4165]="ER_GALERA_REPLICATION_NOT_SUPPORTED";i[4166]="ER_LOAD_INFILE_CAPABILITY_DISABLED";i[4167]="ER_NO_SECURE_TRANSPORTS_CONFIGURED";i[4168]="ER_SLAVE_IGNORED_SHARED_TABLE";i[4169]="ER_NO_AUTOINCREMENT_WITH_UNIQUE";i[4170]="ER_KEY_CONTAINS_PERIOD_FIELDS";i[4171]="ER_KEY_CANT_HAVE_WITHOUT_OVERLAPS";i[4172]="ER_NOT_ALLOWED_IN_THIS_CONTEXT";i[4173]="ER_DATA_WAS_COMMITED_UNDER_ROLLBACK";i[4174]="ER_PK_INDEX_CANT_BE_IGNORED";i[4175]="ER_BINLOG_UNSAFE_SKIP_LOCKED";i[4176]="ER_JSON_TABLE_ERROR_ON_FIELD";i[4177]="ER_JSON_TABLE_ALIAS_REQUIRED";i[4178]="ER_JSON_TABLE_SCALAR_EXPECTED";i[4179]="ER_JSON_TABLE_MULTIPLE_MATCHES";i[4180]="ER_WITH_TIES_NEEDS_ORDER";i[4181]="ER_REMOVED_ORPHAN_TRIGGER";i[4182]="ER_STORAGE_ENGINE_DISABLED";i[4183]="WARN_SFORMAT_ERROR";i[4184]="ER_PARTITION_CONVERT_SUBPARTITIONED";i[4185]="ER_PROVIDER_NOT_LOADED";i[4186]="ER_JSON_HISTOGRAM_PARSE_FAILED";i[4187]="ER_SF_OUT_INOUT_ARG_NOT_ALLOWED";i[4188]="ER_INCONSISTENT_SLAVE_TEMP_TABLE";i[4189]="ER_VERS_HIST_PART_FAILED";i[4190]="WARN_OPTION_CHANGING";i[4191]="ER_CM_OPTION_MISSING_REQUIREMENT";i[4192]="ER_SLAVE_STATEMENT_TIMEOUT";i[4193]="ER_JSON_INVALID_VALUE_FOR_KEYWORD";i[4194]="ER_JSON_SCHEMA_KEYWORD_UNSUPPORTED";i[4195]="ER_JSON_NO_VARIABLE_SCHEMA";i[4196]="ER_SEQUENCE_TABLE_HAS_WRONG_NUMBER_OF_COLUMNS";i[4197]="ER_SEQUENCE_TABLE_CANNOT_HAVE_ANY_KEYS";i[4198]="ER_SEQUENCE_TABLE_CANNOT_HAVE_ANY_CONSTRAINTS";i[4199]="ER_SEQUENCE_TABLE_ORDER_BY";i[4200]="ER_VARIABLE_IGNORED";i[4201]="ER_INCORRECT_COLUMN_NAME_COUNT";i[4202]="WARN_SORTING_ON_TRUNCATED_LENGTH";i[4203]="ER_VECTOR_BINARY_FORMAT_INVALID";i[4204]="ER_VECTOR_FORMAT_INVALID";i[4205]="ER_PSEUDO_THREAD_ID_OVERWRITE";i[4206]="ER_VEC_DISTANCE_TYPE";i[4207]="WARN_INDEX_HINTS_IGNORED";i[4208]="ER_SIGNAL_SKIP_ROW_FROM_TRIGGER";i[4209]="ER_TEMPORARY_TABLES_PREVENT_SWITCH_GTID_DOMAIN_ID";i[4210]="ER_TOO_MANY_OPEN_CURSORS";i[4211]="ER_INCOMPATIBLE_EVENT_FLAG";i[4212]="ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS";i[4213]="ER_LONGITUDE_OUT_OF_RANGE";i[4214]="ER_LATITUDE_OUT_OF_RANGE";i[4215]="ER_GIS_DIFFERENT_SRIDS_AGGREGATION";i[4216]="ER_SEQUENCE_TABLE_HAS_TOO_FEW_ROWS";i[4217]="ER_SEQUENCE_TABLE_HAS_TOO_MANY_ROWS";i[4218]="ER_WARN_OPTIMIZER_HINT_SYNTAX_ERROR";i[4219]="ER_WARN_CONFLICTING_HINT";i[4220]="ER_WARN_UNKNOWN_QB_NAME";i[4221]="ER_UNRESOLVED_TABLE_HINT_NAME";i[4222]="ER_UNRESOLVED_INDEX_HINT_NAME";i[4223]="ER_HINTS_INSIDE_VIEWS_NOT_SUPPORTED";i[4224]="ER_WARN_MALFORMED_HINT";i[4225]="ER_WARN_HINTS_ON_INSERT_PART_OF_INSERT_SELECT";i[4226]="ER_INIT_SLAVE_ERROR";i[4227]="ER_ACTIVE_CONNECTIONS_FOR_USER_TO_DROP";var ir=i;var ve=class extends Error{constructor(e,s,t,n,o,a,A,u=void 0,h){super((u!==!1?`(conn:${n&&n.threadId?n.threadId:-1}, no: ${a||-1}, SQLState: ${o}) `:"")+e+(s?` sql: `+s:""),h),this.name="SqlError",this.sqlMessage=e,this.sql=s,this.fatal=t,this.errno=a,this.sqlState=o,a>45e3&&a<46e3?this.code=rr(a)||"UNKNOWN":this.code=ir[this.errno]||"UNKNOWN",A&&(this.stack+=` From event: `+A.substring(A.indexOf(` `)+1))}get text(){return this.sqlMessage}};function f(E,e,s=null,t="HY000",n=null,o=!1,a=void 0,A=void 0,u=void 0){return u?new ve(E,n,o,s,t,e,a,A,{cause:u}):new ve(E,n,o,s,t,e,a,A,u)}function w(E,e,s=null,t="08S01",n=null,o=void 0,a=void 0){return new ve(E,n,!0,s,t,e,o,a)}var N={ER_CONNECTION_ALREADY_CLOSED:45001,ER_MYSQL_CHANGE_USER_BUG:45003,ER_CMD_NOT_EXECUTED_DESTROYED:45004,ER_NULL_CHAR_ESCAPEID:45005,ER_NULL_ESCAPEID:45006,ER_NOT_IMPLEMENTED_FORMAT:45007,ER_NODE_NOT_SUPPORTED_TLS:45008,ER_SOCKET_UNEXPECTED_CLOSE:45009,ER_UNEXPECTED_PACKET:45011,ER_CONNECTION_TIMEOUT:45012,ER_CMD_CONNECTION_CLOSED:45013,ER_CHANGE_USER_BAD_PACKET:45014,ER_PING_BAD_PACKET:45015,ER_MISSING_PARAMETER:45016,ER_PARAMETER_UNDEFINED:45017,ER_PLACEHOLDER_UNDEFINED:45018,ER_SOCKET:45019,ER_EOF_EXPECTED:45020,ER_LOCAL_INFILE_DISABLED:45021,ER_LOCAL_INFILE_NOT_READABLE:45022,ER_SERVER_SSL_DISABLED:45023,ER_AUTHENTICATION_BAD_PACKET:45024,ER_AUTHENTICATION_PLUGIN_NOT_SUPPORTED:45025,ER_SOCKET_TIMEOUT:45026,ER_POOL_ALREADY_CLOSED:45027,ER_GET_CONNECTION_TIMEOUT:45028,ER_SETTING_SESSION_ERROR:45029,ER_INITIAL_SQL_ERROR:45030,ER_BATCH_WITH_NO_VALUES:45031,ER_RESET_BAD_PACKET:45032,ER_WRONG_IANA_TIMEZONE:45033,ER_LOCAL_INFILE_WRONG_FILENAME:45034,ER_ADD_CONNECTION_CLOSED_POOL:45035,ER_WRONG_AUTO_TIMEZONE:45036,ER_CLOSING_POOL:45037,ER_TIMEOUT_NOT_SUPPORTED:45038,ER_INITIAL_TIMEOUT_ERROR:45039,ER_DUPLICATE_FIELD:45040,ER_PING_TIMEOUT:45042,ER_BAD_PARAMETER_VALUE:45043,ER_CANNOT_RETRIEVE_RSA_KEY:45044,ER_MINIMUM_NODE_VERSION_REQUIRED:45045,ER_MAX_ALLOWED_PACKET:45046,ER_NOT_SUPPORTED_AUTH_PLUGIN:45047,ER_COMPRESSION_NOT_SUPPORTED:45048,ER_UNDEFINED_SQL:45049,ER_PARSING_PRECISION:45050,ER_PREPARE_CLOSED:45051,ER_MISSING_SQL_PARAMETER:45052,ER_MISSING_SQL_FILE:45053,ER_SQL_FILE_ERROR:45054,ER_MISSING_DATABASE_PARAMETER:45055,ER_SELF_SIGNED:45056,ER_SELF_SIGNED_NO_PWD:45057,ER_PRIVATE_FIELDS_USE:45058,ER_TLS_IDENTITY_ERROR:45059,ER_POOL_NOT_INITIALIZED:45060,ER_POOL_NO_CONNECTION:45061,ER_SELF_SIGNED_BAD_PLUGIN:45062,ER_SELF_SIGNED_SHA256:45063,ER_CLEAR_PASSWORD_WITHOUT_SSL:45064};function rr(E){for(let[e,s]of Object.entries(N))if(s===E)return e}var nr=m(require("node:events"),1);var Ss=class extends nr.default{constructor(e,s,t){super(),this.cmdParam=e,this.sequenceNo=-1,this.compressSequenceNo=-1,this.resolve=s,this.reject=t,this.sending=!1,this.unexpectedError=this.throwUnexpectedError.bind(this)}displaySql(){return null}throwUnexpectedError(e,s,t,n,o){let a=f(e,o,t,n,this.opts&&this.opts.logParam?this.displaySql():this.sql,s,this.cmdParam?this.cmdParam.stack:null,!1);return this.reject&&(process.nextTick(this.reject,a),this.resolve=null,this.reject=null),a}throwNewError(e,s,t,n,o){this.onPacketReceive=null;let a=this.throwUnexpectedError(e,s,t,n,o);return this.emit("end"),a}sendCancelled(e,s,t){let n=f(e,s,t,"HY000",this.opts.logParam?this.displaySql():this.sql);this.emit("send_end"),this.throwError(n,t)}throwError(e,s){this.onPacketReceive=null,this.reject&&(this.cmdParam&&this.cmdParam.stack&&(e=f(e.text?e.text:e.message,e.errno,s,e.sqlState,e.sql,e.fatal,this.cmdParam.stack,!1)),this.resolve=null,process.nextTick(this.reject,e),this.reject=null),this.emit("end",e)}successEnd(e){this.onPacketReceive=null,this.resolve&&(this.reject=null,process.nextTick(this.resolve,e),this.resolve=null),this.emit("end")}},re=Ss;var r=[],T=[],_=class{constructor(e,s,t,n){this.index=e,this.name=s,this.charset=t,this.maxLength=n}static fromCharset(e){return T[e==="utf8mb3"?"utf8":e]}static fromIndex(e){if(!(e>=r.length))return r[e]}static fromCharsetAndName(e,s){for(let n=0;n0){let o=e.subPacketLengthEncoded(n);for(;o.remaining();)switch(o.readUInt8()){case 0:this._dataTypeName=o.readBufferLengthEncodedCopy();break;case 1:this._dataTypeFormat=o.readBufferLengthEncodedCopy();break;default:o.skip(o.readUnsignedLength());break}}}e.skip(1),this.collation=P.fromIndex(e.readUInt16()),this.columnLength=e.readUInt32(),this.columnType=e.readUInt8(),this.flags=e.readUInt16(),this.scale=e.readUInt8(),this.type=or[this.columnType]}__getDefaultGeomVal(){let e=this._dataTypeName;return e?Buffer.compare(e,Sn)===0?Un:Buffer.compare(e,fn)===0?Ln:Buffer.compare(e,Cn)===0?Pn:Buffer.compare(e,Tn)===0?mn:Buffer.compare(e,On)===0?Dn:Buffer.compare(e,dn)===0?wn:{type:e.toString("ascii")}:null}isDataTypeFormatJson(){return this._dataTypeFormat!=null&&Buffer.compare(this._dataTypeFormat,pn)===0}get dataTypeName(){return this._dataTypeName?this._dataTypeName.toString("ascii"):void 0}db(){return this.#e.db()}schema(){return this.#e.schema()}table(){return this.#e.table()}orgTable(){return this.#e.orgTable()}name(){return this.#e.name()}orgName(){return this.#e.orgName()}signed(){return(this.flags&32)===0}isSet(){return(this.flags&2048)!==0}},Ft=class{constructor(e,s,t,n){this.buf=t,this.encoding=e,this.readString=s,this.initialPos=n}_readIdentifier(e){let s=this.initialPos;for(;e-- >0;){let o=this.buf[s++];s+=o<251?o:2+this.buf[s]+(this.buf[s+1]<<8)}let t=this.buf[s++],n=t<251?t:this.buf[s++]+(this.buf[s++]<<8);return this.readString(this.encoding,this.buf,s,n)}name(){return this._readIdentifier(3)}db(){let e=this.initialPos;return this.readString(this.encoding,this.buf,e+1,this.buf[e])}schema(){return this.db()}table(){let e=this.initialPos+1+this.buf[this.initialPos],s=this.buf[e++],t=s<251?s:this.buf[e++]+(this.buf[e++]<<8);return this.readString(this.encoding,this.buf,e,t)}orgTable(){return this._readIdentifier(2)}orgName(){return this._readIdentifier(4)}},ds=class extends Ft{constructor(e){e.skip(e.readUInt8());let s=e.pos;e.skip(e.readUInt8()),e.skip(e.readMetadataLength()),e.skip(e.readUInt8()),e.skip(e.readMetadataLength()),e.skip(e.readUInt8()),super(e.encoding,e.constructor.readString,e.buf,s)}},ps=class extends Ft{colName;constructor(e){e.skip(e.readUInt8());let s=e.pos;e.skip(e.readUInt8()),e.skip(e.readMetadataLength()),e.skip(e.readUInt8());let t=e.readStringLengthEncoded();e.skip(e.readUInt8()),super(e.encoding,e.constructor.readString,e.buf,s),this.colName=t}name(){return this.colName}},Ht=Os;var Vr=m(require("node:fs"),1);var l={Normal:1,String:2,SlashStarComment:3,Escape:4,EOLComment:5,Backtick:6,Placeholder:7},Fe=47,it=42,Us=92,Ls=35,rt=45,Ps=10,_t=34,nt=39,ms=96,Sr=63,gn=58,bn=59;function fr(E){let e=[],s=l.Normal,t=0,n=!1,o,a=E.length;for(let A=0;A=48&&E[I+S]<=57||E[I+S]>=65&&E[I+S]<=90||E[I+S]>=97&&E[I+S]<=122||E[I+S]===45||E[I+S]===95;)S++;o.push(I,I+S);let C=E.toString("utf8",I+1,I+S);I+=S;let d;if(C in n?(d=n[C],delete n[C]):d=s[C],d===void 0)throw f(`Placeholder '${C}' is not defined`,N.ER_PLACEHOLDER_UNDEFINED,e,"HY000",t.call());a.push(d)}break;case ms:A===l.Backtick?A=l.Normal:A===l.Normal&&(A=l.Backtick);break}u=c}return{paramPositions:o,values:a}}function yt(E){let e="",s=[],t=l.Normal,n="\0",o=!1,a=0,A=0,u=E.charAt(A++),h;for(;u!=="";){if(t===l.Escape&&!(u==="'"&&o||u==='"'&&!o)){t=l.String,n=u,u=E.charAt(A++);continue}switch(u){case"*":t===l.Normal&&n==="/"&&(t=l.SlashStarComment);break;case"/":if(t===l.SlashStarComment&&n==="*"){t=l.Normal,n="\0",u=E.charAt(A++);continue}break;case"#":t===l.Normal&&(t=l.EOLComment);break;case"-":if(t===l.Normal&&n==="-"){let c=E.charAt(A);(c===""||c<=" ")&&(t=l.EOLComment)}break;case` `:t===l.EOLComment&&(t=l.Normal);break;case'"':t===l.Normal?(t=l.String,o=!1):t===l.String&&!o?t=l.Normal:t===l.Escape&&!o&&(t=l.String);break;case"'":t===l.Normal?(t=l.String,o=!0):t===l.String&&o?(t=l.Normal,o=!1):t===l.Escape&&o&&(t=l.String);break;case"\\":t===l.String&&(t=l.Escape);break;case":":if(t===l.Normal){for(e+=E.substring(a,A-1)+"?",h="";(u=E.charAt(A++))!==""&&u>="0"&&u<="9"||u>="A"&&u<="Z"||u>="a"&&u<="z"||u==="-"||u==="_";)h+=u;A--,s.push(h),a=A}break;case"`":t===l.Backtick?t=l.Normal:t===l.Normal&&(t=l.Backtick)}n=u,u=E.charAt(A++)}return a===0?e=E:e+=E.substring(a),{sql:e,placeHolderIndex:s}}function Tr(E,e,s){let t=new RegExp("^(\\s*\\/\\*([^\\*]|\\*[^\\/])*\\*\\/)*\\s*LOAD\\s+DATA\\s+((LOW_PRIORITY|CONCURRENT)\\s+)?LOCAL\\s+INFILE\\s+'"+s.replace(/\\/g,"\\\\\\\\").replace(".","\\.")+"'","i");return t.test(E)?!0:e!=null&&(t=new RegExp("^(\\s*\\/\\*([^\\*]|\\*[^\\/])*\\*\\/)*\\s*LOAD\\s+DATA\\s+((LOW_PRIORITY|CONCURRENT)\\s+)?LOCAL\\s+INFILE\\s+\\?","i"),t.test(E)&&e.length>0)?Array.isArray(e)?e[0].toLowerCase()===s.toLowerCase():e.toLowerCase()===s.toLowerCase():!1}function Or(E){let e=l.Normal,s=0,t,n=[],o=!1;for(let a=E.offset;a>3,t=E.buf.subarray(E.pos,E.pos+s);return E.pos+=s,t}function Lr(E,e,s,t,n){let o=(t[n+2>>3]&1<<(n+2&7))>0;E.string=()=>o?null:e.readStringLengthEncoded(),E.buffer=()=>o?null:e.readBufferLengthEncoded(),E.float=()=>o?null:e.readFloat(),E.tiny=()=>o?null:E.signed()?e.readInt8():e.readUInt8(),E.short=()=>o?null:E.signed()?e.readInt16():e.readUInt16(),E.int=()=>o?null:e.readInt32(),E.long=()=>o?null:e.readBigInt64(),E.decimal=()=>o?null:e.readDecimalLengthEncoded(),E.date=()=>o?null:e.readBinaryDate(s),E.datetime=()=>o?null:e.readBinaryDateTime(),E.geometry=()=>{let a=E.__getDefaultGeomVal();return o?a:e.readGeometry(a)}}function Ms(E,e){let s=E.signed()?Oe[E.columnType]:de[E.columnType];if(s)return s;switch(E.columnType){case 8:return E.signed()?e.bigIntAsNumber||e.supportBigNumbers?Yn:Vn:e.bigIntAsNumber||e.supportBigNumbers?Wn:xn;case 12:case 7:return e.dateStrings?Qn.bind(null,E.scale):vn;case 0:case 246:return E.scale===0?qn:Xn;case 255:let t=E.__getDefaultGeomVal();return Kn.bind(null,t);case 16:return E.columnLength===1&&e.bitOneIsBoolean?jn:pr;case 245:return e.jsonStrings?Ur:dr;default:return E.isDataTypeFormatJson()&&e.autoJsonMap?dr:E.collation.index===63?pr:E.isSet()?$n:Ur}}var D=(E,e)=>(e[E+2>>3]&1<<(E+2&7))>0,Bn=(E,e,s,t,n)=>D(n,t)?null:E.readInt8(),Gn=(E,e,s,t,n)=>D(n,t)?null:E.readUInt8(),Pr=(E,e,s,t,n)=>D(n,t)?null:E.readInt16(),mr=(E,e,s,t,n)=>D(n,t)?null:E.readUInt16(),Fn=(E,e,s,t,n)=>{if(D(n,t))return null;let o=E.readInt24();return E.skip(1),o},Hn=(E,e,s,t,n)=>{if(D(n,t))return null;let o=E.readUInt24();return E.skip(1),o},yn=(E,e,s,t,n)=>D(n,t)?null:E.readInt32(),kn=(E,e,s,t,n)=>D(n,t)?null:E.readUInt32(),Dr=(E,e,s,t,n)=>D(n,t)?null:E.readFloat(),wr=(E,e,s,t,n)=>D(n,t)?null:E.readDouble(),xn=function(E,e,s,t,n){return D(n,t)?null:E.readBigUInt64()},Vn=function(E,e,s,t,n){return D(n,t)?null:E.readBigInt64()},Wn=function(E,e,s,t,n){if(D(n,t))return null;let o=E.readBigUInt64();return e.bigIntAsNumber&&e.checkNumberRange&&!Number.isSafeInteger(Number(o))?s(`value ${o} can't safely be converted to number`,!1,null,"42000",N.ER_PARSING_PRECISION):e.supportBigNumbers&&(e.bigNumberStrings||!Number.isSafeInteger(Number(o)))?o.toString():Number(o)},Yn=function(E,e,s,t,n){if(D(n,t))return null;let o=E.readBigInt64();return e.bigIntAsNumber&&e.checkNumberRange&&!Number.isSafeInteger(Number(o))?s(`value ${o} can't safely be converted to number`,!1,null,"42000",N.ER_PARSING_PRECISION):e.supportBigNumbers&&(e.bigNumberStrings||!Number.isSafeInteger(Number(o)))?o.toString():Number(o)},Kn=(E,e,s,t,n,o)=>D(o,n)?E:e.readGeometry(E),gr=(E,e,s,t,n)=>D(n,t)?null:E.readBinaryDate(e),vn=(E,e,s,t,n)=>D(n,t)?null:E.readBinaryDateTime(),Qn=(E,e,s,t,n,o)=>D(o,n)?null:e.readBinaryDateTimeAsString(E),br=(E,e,s,t,n)=>D(n,t)?null:E.readBinaryTime(),qn=(E,e,s,t,n)=>{if(D(n,t))return null;let o=E.readDecimalLengthEncoded();return o!=null&&(e.decimalAsNumber||e.supportBigNumbers)?e.decimalAsNumber&&e.checkNumberRange&&!Number.isSafeInteger(Number(o))?s(`value ${o} can't safely be converted to number`,!1,null,"42000",N.ER_PARSING_PRECISION):e.supportBigNumbers&&(e.bigNumberStrings||!Number.isSafeInteger(Number(o)))?o:Number(o):o},Xn=(E,e,s,t,n)=>{if(D(n,t))return null;let o=E.readDecimalLengthEncoded();if(o!=null&&(e.decimalAsNumber||e.supportBigNumbers)){let a=Number(o);return e.supportBigNumbers&&(e.bigNumberStrings||Number.isInteger(a)&&!Number.isSafeInteger(a))?o:a}return o},dr=(E,e,s,t,n)=>D(n,t)?null:JSON.parse(E.readStringLengthEncoded()),jn=(E,e,s,t,n)=>D(n,t)?null:E.readBufferLengthEncoded()[0]===1,pr=(E,e,s,t,n)=>D(n,t)?null:E.readBufferLengthEncoded(),$n=(E,e,s,t,n)=>{if(D(n,t))return null;let o=E.readStringLengthEncoded();return o==null?null:o===""?[]:o.split(",")},Ur=(E,e,s,t,n)=>D(n,t)?null:E.readStringLengthEncoded(),Oe=Array(256);Oe[1]=Bn;Oe[13]=Pr;Oe[2]=Pr;Oe[9]=Fn;Oe[3]=yn;Oe[4]=Dr;Oe[5]=wr;Oe[10]=gr;Oe[11]=br;var de=Array(256);de[1]=Gn;de[13]=mr;de[2]=mr;de[9]=Hn;de[3]=kn;de[4]=Dr;de[5]=wr;de[10]=gr;de[11]=br;var Mr=1024;function Bs(E,e){let s=he[E.columnType];if(s)return s;switch(E.columnType){case 0:case 246:return E.scale===0?ro:_o;case 8:return e.bigIntAsNumber||e.supportBigNumbers?io:Jn;case 255:let t=E.__getDefaultGeomVal();return function(n,o,a){return n.readGeometry(t)};case 16:return E.columnLength===1&&e.bitOneIsBoolean?eo:Gr;case 245:return e.jsonStrings?Br:Fr;default:return E.isDataTypeFormatJson()&&e.autoJsonMap?Fr:E.collation.index===63?Gr:E.isSet()?to:Br}}function Hr(E,e,s,t,n){let o=e;E.string=()=>o.readStringLengthEncoded(),E.buffer=()=>o.readBufferLengthEncoded(),E.float=()=>o.readFloatLengthCoded(),E.tiny=E.short=E.int=()=>o.readIntLengthEncoded(),E.long=()=>o.readBigIntLengthEncoded(),E.decimal=()=>o.readDecimalLengthEncoded(),E.date=()=>o.readDate(s),E.datetime=()=>o.readDateTime(),E.geometry=()=>o.readGeometry(E.__getDefaultGeomVal())}var St=(E,e,s)=>E.readIntLengthEncoded(),Br=(E,e,s)=>E.readStringLengthEncoded(),yr=(E,e,s)=>E.readFloatLengthCoded(),Jn=(E,e,s)=>E.readBigIntLengthEncoded(),zn=(E,e,s)=>E.readAsciiStringLengthEncoded(),eo=(E,e,s)=>{let t=E.readBufferLengthEncoded();return t==null?null:t[0]===1},Gr=(E,e,s)=>E.readBufferLengthEncoded(),Fr=(E,e,s)=>{let t=E.readStringLengthEncoded();return t===null?null:JSON.parse(t)},to=(E,e,s)=>{let t=E.readStringLengthEncoded();return t==null?null:t===""?[]:t.split(",")},so=(E,e,s)=>e.dateStrings?E.readAsciiStringLengthEncoded():E.readDate(),kr=(E,e,s)=>e.dateStrings?E.readAsciiStringLengthEncoded():E.readDateTime(),he=new Array(256);he[1]=St;he[2]=St;he[3]=St;he[9]=St;he[13]=St;he[4]=yr;he[5]=yr;he[10]=so;he[12]=kr;he[7]=kr;he[11]=zn;var io=(E,e,s)=>{let t=E.readUnsignedLength();if(t===null)return null;if(t<16){let a=E._atoi(t);return e.supportBigNumbers&&e.bigNumberStrings?`${a}`:a}if(t>Mr)return E.skip(t),s(`numeric value length (${t}) exceeds maximum of ${Mr} characters - refusing to parse`,!1,null,"42000",N.ER_PARSING_PRECISION);let n=E.readBigIntFromLen(t);if(e.bigIntAsNumber&&e.checkNumberRange&&!Number.isSafeInteger(Number(n)))return s(`value ${n} can't safely be converted to number`,!1,null,"42000",N.ER_PARSING_PRECISION);let o=Number(n);return e.supportBigNumbers&&(e.bigNumberStrings||!Number.isSafeInteger(o))?n.toString():o},ro=(E,e,s)=>{let t=E.readDecimalLengthEncoded();if(t===null)return null;if(!(e.decimalAsNumber||e.supportBigNumbers))return t;let n=Number(t);return e.decimalAsNumber&&e.checkNumberRange&&!Number.isSafeInteger(n)?s(`value ${t} can't safely be converted to number`,!1,null,"42000",N.ER_PARSING_PRECISION):e.supportBigNumbers&&(e.bigNumberStrings||!Number.isSafeInteger(n))?t:n},_o=(E,e,s)=>{let t=E.readDecimalLengthEncoded();if(t===null)return null;if(!(e.decimalAsNumber||e.supportBigNumbers))return t;let n=Number(t);return e.supportBigNumbers&&(e.bigNumberStrings||Number.isInteger(n)&&!Number.isSafeInteger(n))?t:n};var Gs=class{constructor(e,s,t){this.affectedRows=e,this.insertId=s,this.warningStatus=t}},ce=Gs;var Eo=new Set(["__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","__proto__"]),Fs=class E extends re{constructor(e,s,t,n){super(n,e,s),this._responseIndex=0,this._rows=[],this.opts=n.opts?Object.assign({},t,n.opts):t,this.sql=n.sql,this.initialValues=n.values,this.canSkipMeta=!1}readResponsePacket(e,s,t,n){switch(e.peek()){case 0:return this.readOKPacket(e,s,t,n);case 255:return this.handleErrorPacket(e,n);case 251:return this.readLocalInfile(e,s,t,n);default:return this.readResultSet(e,n)}}handleErrorPacket(e,s){this._columns=null;let t=e.readError(s,this.opts.logParam?this.displaySql():this.sql,this.cmdParam.stack);return s.status|=1,this.throwError(t,s)}readResultSet(e,s){if(this._columnCount=e.readUnsignedLength(),this._rows.push([]),this.canSkipMeta&&s.serverPermitSkipMeta&&e.readUInt8()===0)return this.handleSkippedMeta(s);this._columns=[],this.onPacketReceive=this.readColumn}handleSkippedMeta(e){this._columns=this.prepare.columns,this._columnCount=this._columns.length,this.emit("fields",this._columns),this.setParser(),this.onPacketReceive=e.eofDeprecated?this.readResultSetRow:this.readIntermediateEOF}readOKPacket(e,s,t,n){e.skip(1);let o=e.readUnsignedLength(),a=this.processInsertId(e.readInsertId(),n);n.status=e.readUInt16();let A=new ce(o,a,e.readUInt16()),u=!1;return n.status&16384&&(u=this.processSessionStateChanges(e,n,t)),this.inStream&&this.handleNewRows(A),u||(n.redirectRequest&&(n.status&1)===0&&(n.status&8)===0?n.redirect(n.redirectRequest,this.okPacketSuccess.bind(this,A,n)):this.okPacketSuccess(A,n)),null}processInsertId(e,s){return this.opts.supportBigNumbers||this.opts.insertIdAsNumber?this.opts.insertIdAsNumber&&this.opts.checkNumberRange&&!Number.isSafeInteger(Number(e))?(this.onPacketReceive=s.status&8?this.readResponsePacket:null,this.throwUnexpectedError(`last insert id value ${e} can't safely be converted to number`,!1,s,"42000",N.ER_PARSING_PRECISION),e):this.opts.supportBigNumbers&&(this.opts.bigNumberStrings||!Number.isSafeInteger(Number(e)))?e.toString():Number(e):e}processSessionStateChanges(e,s,t){let n=!1;for(e.skipLengthCodedNumber();e.remaining();){let o=e.readUnsignedLength();if(o>0){let a=e.subPacketLengthEncoded(o);for(;a.remaining();)switch(a.readUInt8()){case 0:n=this.processSystemVariables(a,s,t)||n;break;case 1:s.database=this.readSchemaChange(a);break}}}return n}processSystemVariables(e,s,t){let n=!1,o;do{o=e.subPacketLengthEncoded(e.readUnsignedLength());let a=o.readStringLengthEncoded(),A=o.readStringLengthEncoded();switch(a){case"character_set_client":if(s.collation=P.fromCharset(A),s.collation===void 0)return this.throwError(new Error(`unknown charset: '${A}'`),s),!1;t.emit("collation",s.collation);break;case"redirect_url":A!==""&&(n=!0,s.redirect(A,this.okPacketSuccess.bind(this,this.okPacket,s)));break;case"connection_id":s.threadId=parseInt(A);break}}while(o.remaining()>0);return n}readSchemaChange(e){return e.subPacketLengthEncoded(e.readUnsignedLength()).readStringLengthEncoded()}okPacketSuccess(e,s){if(this._responseIndex===0)return s.status&8?(this._rows.push(e),this._responseIndex++,this.onPacketReceive=this.readResponsePacket):this.success(this.opts.metaAsArray?[e,[]]:e);if(this._rows.push(e),s.status&8)return this._responseIndex++,this.onPacketReceive=this.readResponsePacket;this.opts.metaAsArray?(this._meta||(this._meta=new Array(this._responseIndex)),this._meta[this._responseIndex]=null,this.success([this._rows,this._meta])):this.success(this._rows)}success(e){this.successEnd(e),this._columns=null,this._rows=[]}readColumn(e,s,t,n){this._columns.push(new Ht(e,n,this.opts.rowsAsArray)),this._columns.length===this._columnCount&&(this.setParser(),this.canSkipMeta&&n.serverPermitSkipMeta&&this.prepare!=null&&this._responseIndex===0&&(this.prepare.columns=this._columns),this.emit("fields",this._columns),this.onPacketReceive=n.eofDeprecated?this.readResultSetRow:this.readIntermediateEOF)}setParser(){if(this._parseFunction=new Array(this._columnCount),this.opts.typeCast)for(let e=0;e({}))}readIntermediateEOF(e,s,t,n){if(e.peek()!==254)return this.throwNewError("Error in protocol, expected EOF packet",!0,n,"42000",N.ER_EOF_EXPECTED);e.skip(3),n.status=e.readUInt16(),this.isOutParameter=n.status&4096,this.onPacketReceive=this.readResultSetRow}handleNewRows(e){this._rows[this._responseIndex].push(e)}readResultSetRow(e,s,t,n){let o=e.peek();if(o>=254){if(o===255)return n.status|=1,this.throwError(e.readError(n,this.opts.logParam?this.displaySql():this.sql,this.cmdParam.err),n);if(!n.eofDeprecated&&e.length()<13||n.eofDeprecated&&e.length()<16777215){n.eofDeprecated?(e.skip(1),e.skipLengthCodedNumber(),e.skipLengthCodedNumber(),n.status=e.readUInt16()):(e.skip(3),n.status=e.readUInt16()),n.redirectRequest&&(n.status&1)===0&&(n.status&8)===0?n.redirect(n.redirectRequest,this.resultSetEndingPacketResult.bind(this,n)):this.resultSetEndingPacketResult(n);return}}this.handleNewRows(this.parseRow(e))}resultSetEndingPacketResult(e){if(this.opts.metaAsArray){if(e.status&8||this.isOutParameter)return this._meta||(this._meta=[]),this._meta[this._responseIndex]=this._columns,this._responseIndex++,this.onPacketReceive=this.readResponsePacket;this._responseIndex===0?this.success([this._rows[0],this._columns]):(this._meta||(this._meta=[]),this._meta[this._responseIndex]=this._columns,this.success([this._rows,this._meta]))}else{if(Object.defineProperty(this._rows[this._responseIndex],"meta",{value:this._columns,writable:!0,enumerable:this.opts.metaEnumerable}),e.status&8||this.isOutParameter)return this._responseIndex++,this.onPacketReceive=this.readResponsePacket;this.success(this._responseIndex===0?this._rows[0]:this._rows)}}displaySql(){if(this.opts&&this.initialValues){if(this.sql.length>this.opts.debugLen)return this.sql.substring(0,this.opts.debugLen)+"...";let e=this.sql+" - parameters:";return E.logParameters(this.opts,e,this.initialValues)}return this.sql.length>this.opts.debugLen?this.sql.substring(0,this.opts.debugLen)+"... - parameters:[]":this.sql+" - parameters:[]"}static logParameters(e,s,t){if(e.namedPlaceholders){s+="{";let n=!0;for(let o in t){n?n=!1:s+=",",s+="'"+o+"':";let a=t[o];if(s=E.logParam(s,a),s.length>e.debugLen)return s.substring(0,e.debugLen)+"..."}s+="}"}else{if(s+="[",Array.isArray(t))for(let n=0;ne.debugLen)return s.substring(0,e.debugLen)+"..."}else if(s=E.logParam(s,t),s.length>e.debugLen)return s.substring(0,e.debugLen)+"...";s+="]"}return s}parseRowAsArray(e){let s=new Array(this._columnCount),t=this.binary?vt(e,this._columns):null;for(let n=0;n{s.writeBuffer(A,0,A.length)}),a.on("end",()=>{s.isEmpty()||s.flushBuffer(!1),s.writeEmptyPacket()}),this.onPacketReceive=this.readResponsePacket}static logParam(e,s){if(s==null)e+=s===void 0?"undefined":"null";else switch(s.constructor.name){case"Buffer":e+="0x"+s.toString("hex",0,Math.min(1024,s.length));break;case"String":e+="'"+s+"'";break;case"Date":e+=ao(s);break;case"Object":e+=JSON.stringify(s);break;default:e+=s.toString()}return e}};function ao(E){return"'"+("00"+(E.getMonth()+1)).slice(-2)+"/"+("00"+E.getDate()).slice(-2)+"/"+E.getFullYear()+" "+("00"+E.getHours()).slice(-2)+":"+("00"+E.getMinutes()).slice(-2)+":"+("00"+E.getSeconds()).slice(-2)+"."+("000"+E.getMilliseconds()).slice(-3)+"'"}var Se=Fs;var Ao=new Set(["Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon","GeometryCollection"]),$e=function(E,e){let s=`${E}`;return s.length0&&(h+="."+$e(u,3)),h+"'"}},G=xs;var Wr=require("node:stream"),ft=39,Vs=class extends Se{constructor(e,s,t,n){super(e,s,t,n),this.binary=!1}start(e,s,t){if(s.logger.query&&s.logger.query(`QUERY: ${s.logParam?this.displaySql():this.sql}`),this.onPacketReceive=this.readResponsePacket,this.initialValues===void 0){if(e.startPacket(this),e.writeInt8(3),!this.handleTimeout(e,t))return;e.writeString(this.sql),e.flush(),this.emit("send_end");return}if(this.encodedSql=e.encodeString(this.sql),this.opts.namedPlaceholders)try{let o=Cr(this.encodedSql,t,this.initialValues,this.opts.logParam?this.displaySql.bind(this):()=>this.sql);this.paramPositions=o.paramPositions,this.values=o.values}catch(o){return this.emit("send_end"),this.throwError(o,t)}else if(this.paramPositions=fr(this.encodedSql),this.values=Array.isArray(this.initialValues)?this.initialValues:[this.initialValues],!this.validateParameters(t))return;if(e.startPacket(this),e.writeInt8(3),!this.handleTimeout(e,t))return;this.paramPos=0,this.sqlPos=0;let n=this.paramPositions.length/2;for(this.valueIdx=0;this.valueIdxthis.values.length?(this.sendCancelled(`Parameter at position ${this.values.length+1} is not set`,N.ER_MISSING_PARAMETER,e),!1):!0}_paramWritten(e,s){for(;;)if(this.valueIdx===this.paramPositions.length/2){e.writeBuffer(this.encodedSql,this.sqlPos,this.encodedSql.length-this.sqlPos),e.flush(),this.sending=!1,this.emit("send_end");return}else{let t=this.values[this.valueIdx++];if(e.writeBuffer(this.encodedSql,this.sqlPos,this.paramPositions[this.paramPos++]-this.sqlPos),this.sqlPos=this.paramPositions[this.paramPos++],t==null){e.writeStringAscii("NULL");continue}if(typeof t=="object"&&typeof t.pipe=="function"&&typeof t.read=="function"){e.writeInt8(ft),t.once("end",function(){e.writeInt8(ft),this._paramWritten(e,s)}.bind(this)),t.on("data",e.writeBufferEscape.bind(e));return}G.writeParam(e,t,this.opts,s)}}_stream(e,s){return this.socket=e,s=s||{},s.objectMode=!0,s.read=()=>{this.socket.resume()},this.inStream=new Wr.Readable(s),this.on("fields",function(t){this.inStream.emit("fields",t)}),this.on("error",function(t){this.inStream.emit("error",t)}),this.on("close",function(t){this.inStream.emit("error",t)}),this.on("end",function(t){t&&this.inStream.emit("error",t),this.socket.resume(),this.inStream.push(null)}),this.inStream.close=function(){this.handleNewRows=()=>{},this.socket.resume()}.bind(this),this.handleNewRows=function(t){this.inStream.push(t)||this.socket.pause()},this.inStream}},ge=Vs;var Ws=class E{#e;constructor(e){this.#e=e}get threadId(){return this.#e.info?this.#e.info.threadId:null}get info(){return this.#e.info}#t=()=>{};release=e=>{this.#e.release(()=>{e&&e()})};changeUser(e,s){let t,n;typeof e=="function"?(n=e,t=void 0):(t=e,n=s);let o={opts:t,callback:n};this.#e.opts.trace&&Error.captureStackTrace(o),new Promise(this.#e.changeUser.bind(this.#e,o)).then(()=>{o.callback&&o.callback(null,null,null)}).catch(o.callback||this.#t)}beginTransaction(e){this.query("START TRANSACTION",null,e)}commit(e){this.#e.changeTransaction({sql:"COMMIT"},()=>{e&&e(null,null,null)},e||this.#t)}rollback(e){this.#e.changeTransaction({sql:"ROLLBACK"},()=>{e&&e(null,null,null)},e||this.#t)}query(e,s,t){let n=E._PARAM(this.#e.opts,e,s,t);return E._QUERY_CMD(this.#e,n)}queryStream(e,s){let t=E._PARAM(this.#e.opts,e,s);return E._QUERY_CMD(this.#e,t).stream()}static _QUERY_CMD(e,s){let t;return s.callback?(s.opts=s.opts?Object.assign(s.opts,{metaAsArray:!0}):{metaAsArray:!0},t=new ge(([n,o])=>{s.callback(null,n,o)},s.callback,e.opts,s)):t=new ge(()=>{},()=>{},e.opts,s),t.handleNewRows=n=>{t._rows[t._responseIndex].push(n),t.emit("data",n)},e.addCommand(t,!0),t.stream=n=>t._stream(e.socket,n),t}execute(e,s,t){let n=E._PARAM(this.#e.opts,e,s,t);n.opts=n.opts?Object.assign(n.opts,{metaAsArray:!0}):{metaAsArray:!0},this.#e.prepareExecute(n,([o,a])=>{n.callback&&n.callback(null,o,a)},o=>{n.callback&&n.callback(o)})}static _PARAM(e,s,t,n){let o,a,A=t,u=n;typeof t=="function"&&(u=t,A=void 0),typeof s=="object"?(o=s,a=o.sql,o.values&&(A=o.values)):a=s;let h={sql:a,values:A,opts:o,callback:u};return e.trace&&Error.captureStackTrace(h,E._PARAM),h}static _EXECUTE_CMD(e,s){new Promise(e.prepare.bind(e,s)).then(t=>{let n=s.opts?Object.assign(s.opts,{metaAsArray:!0}):{metaAsArray:!0};return t.execute(s.values,n,null,s.stack).then(([o,a])=>{s.callback&&s.callback(null,o,a)}).finally(()=>t.close())}).catch(t=>{e.opts.logger.error&&e.opts.logger.error(t),s.callback&&s.callback(t)})}prepare(e,s){let t,n;typeof e=="object"?(t=e,n=t.sql):n=e;let o={sql:n,opts:t,callback:s};return this.#e.opts.trace&&Error.captureStackTrace(o),new Promise(this.#e.prepare.bind(this.#e,o)).then(a=>{try{s&&s(null,a,null)}catch{}}).catch(s||this.#t)}batch(e,s,t){let n=E._PARAM(this.#e.opts,e,s,t);this.#e.batch(n,o=>{n.callback&&n.callback(null,o)},o=>{n.callback&&n.callback(o)})}importFile(e,s){if(!e||!e.file){s&&s(f("SQL file parameter is mandatory",N.ER_MISSING_SQL_PARAMETER,this.#e.info,"HY000",null,!1,null));return}new Promise(this.#e.importFile.bind(this.#e,{file:e.file,database:e.database})).then(()=>{s&&s()}).catch(t=>{s&&s(t)})}ping(e,s){let t={},n;typeof e=="function"?n=e:(t.timeout=e,n=s);let o={opts:t,callback:n};this.#e.opts.trace&&Error.captureStackTrace(o),new Promise(this.#e.ping.bind(this.#e,o)).then(n||this.#t).catch(n||this.#t)}reset(e){let s={};return this.#e.opts.trace&&Error.captureStackTrace(s),new Promise(this.#e.reset.bind(this.#e,s)).then(e||this.#t).catch(e||this.#t)}isValid(){return this.#e.isValid()}end(e){let s={};this.#e.opts.trace&&Error.captureStackTrace(s),new Promise(this.#e.end.bind(this.#e,s)).then(()=>{e&&e()}).catch(e||this.#t)}close(){this.destroy()}destroy(){this.#e.destroy()}pause(){this.#e.pause()}resume(){this.#e.resume()}format(e,s){this.#e.format(e,s)}serverVersion(){return this.#e.serverVersion()}debug(e){return this.#e.debug(e)}debugCompress(e){return this.#e.debugCompress(e)}escape(e){return this.#e.escape(e)}escapeId(e){return this.#e.escapeId(e)}get __tests(){return this.#e.__tests}connect(e){if(!e)throw new f("missing mandatory callback parameter",N.ER_MISSING_PARAMETER,this.#e.info);switch(this.#e.status){case 1:case 2:case 3:case 4:this.once("connect",e);break;case 5:e.call(this);break;case 6:case 7:case 8:e.call(this,f("Connection closed",N.ER_CONNECTION_ALREADY_CLOSED,this.#e.info,"08S01",null,!0));break}}on(e,s){return this.#e.on.call(this.#e,e,s),this}off(e,s){return this.#e.off.call(this.#e,e,s),this}once(e,s){return this.#e.once.call(this.#e,e,s),this}listeners(e){return this.#e.listeners.call(this.#e,e)}addListener(e,s){return this.#e.addListener.call(this.#e,e,s),this}eventNames(){return this.#e.eventNames.call(this.#e)}getMaxListeners(){return this.#e.getMaxListeners.call(this.#e)}listenerCount(e,s){return this.#e.listenerCount.call(this.#e,e,s)}prependListener(e,s){return this.#e.prependListener.call(this.#e,e,s),this}prependOnceListener(e,s){return this.#e.prependOnceListener.call(this.#e,e,s),this}removeAllListeners(e,s){return this.#e.removeAllListeners.call(this.#e,e,s),this}removeListener(e,s){return this.#e.removeListener.call(this.#e,e,s),this}setMaxListeners(e){return this.#e.setMaxListeners.call(this.#e,e),this}rawListeners(e){return this.#e.rawListeners.call(this.#e,e)}},be=Ws;var Ks=class{constructor(e){e?(this.canRetry=e.canRetry===void 0?!0:!!e.canRetry,this.removeNodeErrorCount=e.removeNodeErrorCount===void 0?Number.POSITIVE_INFINITY:Number(e.removeNodeErrorCount),this.restoreNodeTimeout=e.restoreNodeTimeout===void 0?1e3:Number(e.restoreNodeTimeout),this.defaultSelector=e.defaultSelector||"RR"):(this.canRetry=!0,this.removeNodeErrorCount=Number.POSITIVE_INFINITY,this.restoreNodeTimeout=1e3,this.defaultSelector="RR")}},Xt=Ks;var uo=/mariadb:\/\/(([^/@:]+)?(:([^/]+))?@)?(([^/:]+)(:([0-9]+))?)\/([^?]+)(\?(.*))?$/,vs=class E{constructor(e){if(typeof e=="string"&&(e=E.parse(e)),e||(e={}),this.host=e.host||"localhost",this.port=e.port?Number(e.port):3306,this.keepEof=!!e.keepEof||!1,this.user=e.user||process.env.USERNAME,this.password=e.password,this.database=e.database,this.stream=e.stream,this.fullResult=e.fullResult,this.debug=!!e.debug||!1,this.debugCompress=!!e.debugCompress||!1,this.debugLen=e.debugLen?Number(e.debugLen):256,this.logParam=e.logParam===void 0?!0:!!e.logParam,e.logger?typeof e.logger=="function"?this.logger={network:e.logger,query:e.logger,error:e.logger,warning:e.logger}:(this.logger={network:e.logger.network,query:e.logger.query,error:e.logger.error,warning:e.logger.warning||console.log},e.logger.logParam!==void 0&&(this.logParam=!!e.logger.logParam)):this.logger={network:this.debug||this.debugCompress?console.log:null,query:null,error:null,warning:console.log},this.debug=!!this.logger.network,e.charset&&typeof e.charset=="string"){if(e.collation&&typeof e.collation=="string"&&(this.collation=P.fromCharsetAndName(e.charset.toLowerCase(),e.collation.toUpperCase()),this.collation===void 0))throw new RangeError("Unknown collation '"+e.collation+"' with charset '"+e.charset+"'");this.collation=P.fromCharset(e.charset.toLowerCase()),this.collation===void 0&&(this.collation=P.fromName(e.charset.toUpperCase()),this.collation!==void 0?this.logger.warning("warning: please use option 'collation' in replacement of 'charset' when using a collation name ('"+e.charset+`') (collation looks like 'UTF8MB4_UNICODE_CI', charset like 'utf8').`):this.charset=e.charset)}else if(e.collation&&typeof e.collation=="string"){if(this.collation=P.fromName(e.collation.toUpperCase()),this.collation===void 0)throw new RangeError("Unknown collation '"+e.collation+"'")}else this.collation=e.charsetNumber?P.fromIndex(Number(e.charsetNumber)):void 0;if(this.initSql=e.initSql,this.connectTimeout=e.connectTimeout===void 0?1e3:Number(e.connectTimeout),this.connectAttributes=e.connectAttributes||!1,this.compress=!!e.compress||!1,this.rsaPublicKey=e.rsaPublicKey,this.cachingRsaPublicKey=e.cachingRsaPublicKey,this.allowPublicKeyRetrieval=!!e.allowPublicKeyRetrieval||!1,this.forceVersionCheck=!!e.forceVersionCheck||!1,this.maxAllowedPacket=e.maxAllowedPacket?Number(e.maxAllowedPacket):void 0,this.permitConnectionWhenExpired=!!e.permitConnectionWhenExpired||!1,this.pipelining=e.pipelining,this.timezone=e.timezone||"local",this.socketPath=e.socketPath,this.sessionVariables=e.sessionVariables,this.infileStreamFactory=e.infileStreamFactory,this.ssl=e.ssl,e.ssl&&typeof e.ssl!="boolean"&&typeof e.ssl!="string"&&(this.ssl.rejectUnauthorized=e.ssl.rejectUnauthorized!==!1),this.permitRedirect=e.permitRedirect===void 0?!!this.ssl&&this.ssl.rejectUnauthorized!==!1:!!e.permitRedirect,this.queryTimeout=isNaN(e.queryTimeout)||Number(e.queryTimeout)<0?0:Number(e.queryTimeout),this.socketTimeout=isNaN(e.socketTimeout)||Number(e.socketTimeout)<0?0:Number(e.socketTimeout),this.keepAliveDelay=e.keepAliveDelay===void 0?void 0:Number(e.keepAliveDelay),e.keepAliveDelay||e.enableKeepAlive===!0&&e.keepAliveInitialDelay!==void 0&&(this.keepAliveDelay=Number(e.keepAliveInitialDelay)),this.trace=!!e.trace||!1,this.checkDuplicate=e.checkDuplicate===void 0?!0:!!e.checkDuplicate,this.dateStrings=!!e.dateStrings||!1,this.foundRows=e.foundRows===void 0||!!e.foundRows,this.metaAsArray=!!e.metaAsArray||!1,this.metaEnumerable=!!e.metaEnumerable||!1,this.multipleStatements=!!e.multipleStatements||!1,this.namedPlaceholders=!!e.namedPlaceholders||!1,this.nestTables=e.nestTables,this.autoJsonMap=e.autoJsonMap===void 0?!0:!!e.autoJsonMap,this.jsonStrings=!!e.jsonStrings||!1,e.jsonStrings!==void 0&&(this.autoJsonMap=!this.jsonStrings),this.bitOneIsBoolean=e.bitOneIsBoolean===void 0?!0:!!e.bitOneIsBoolean,this.arrayParenthesis=!!e.arrayParenthesis||!1,this.permitSetMultiParamEntries=!!e.permitSetMultiParamEntries||!1,this.rowsAsArray=!!e.rowsAsArray||!1,this.typeCast=e.typeCast,this.typeCast!==void 0&&typeof this.typeCast!="function"&&(this.typeCast=void 0),this.bulk=e.bulk===void 0||!!e.bulk,this.checkNumberRange=!!e.checkNumberRange||!1,e.pipelining===void 0)this.permitLocalInfile=!!e.permitLocalInfile||!1,this.pipelining=!this.permitLocalInfile;else{if(this.pipelining=!!e.pipelining,e.permitLocalInfile===!0&&this.pipelining)throw new Error("enabling options `permitLocalInfile` and `pipelining` is not possible, options are incompatible.");this.permitLocalInfile=this.pipelining?!1:!!e.permitLocalInfile||!1}if(this.prepareCacheLength=e.prepareCacheLength===void 0?256:Number(e.prepareCacheLength),this.restrictedAuth=e.restrictedAuth,this.restrictedAuth!=null&&(Array.isArray(this.restrictedAuth)||(this.restrictedAuth=this.restrictedAuth.split(","))),this.bigIntAsNumber=!!e.bigIntAsNumber||!1,this.insertIdAsNumber=!!e.insertIdAsNumber||!1,this.decimalAsNumber=!!e.decimalAsNumber||!1,this.supportBigNumbers=!!e.supportBigNumbers||!1,this.bigNumberStrings=!!e.bigNumberStrings||!1,e.maxAllowedPacket&&isNaN(this.maxAllowedPacket))throw new RangeError(`maxAllowedPacket must be an integer. was '${e.maxAllowedPacket}'`)}static parseOptionDataType(e){if(["bulk","allowPublicKeyRetrieval","insertIdAsNumber","decimalAsNumber","bigIntAsNumber","permitRedirect","logParam","compress","dateStrings","debug","autoJsonMap","arrayParenthesis","checkDuplicate","debugCompress","foundRows","metaAsArray","metaEnumerable","multipleStatements","namedPlaceholders","nestTables","permitSetMultiParamEntries","pipelining","forceVersionCheck","rowsAsArray","trace","bitOneIsBoolean","jsonStrings","enableKeepAlive","supportBigNumbers","bigNumberStrings","keepEof","permitLocalInfile","permitConnectionWhenExpired"].forEach(n=>{e[n]!==void 0&&typeof e[n]=="string"&&(e[n]=e[n]==="true")}),["charsetNumber","connectTimeout","keepAliveDelay","socketTimeout","debugLen","prepareCacheLength","queryTimeout","maxAllowedPacket","keepAliveInitialDelay","port"].forEach(n=>{if(e[n]!==void 0&&typeof e[n]=="string"){let o=parseInt(e[n],10);isNaN(o)||(e[n]=o)}}),e.ssl!==void 0&&typeof e.ssl=="string"&&(e.ssl=e.ssl==="true"),e.connectAttributes!==void 0&&typeof e.connectAttributes=="string")try{e.connectAttributes=JSON.parse(e.connectAttributes)}catch(n){throw new Error(`Failed to parse connectAttributes as JSON: ${n.message}`)}if(e.sessionVariables!==void 0&&typeof e.sessionVariables=="string"&&e.sessionVariables.trim().startsWith("{"))try{e.sessionVariables=JSON.parse(e.sessionVariables)}catch{}return e}static parse(e){let s=e.match(uo);if(!s)throw new Error("error parsing connection string "+e+". format must be 'mariadb://[[:]@][:]/[[?=[&=]]]'");let t={user:s[2]?decodeURIComponent(s[2]):void 0,password:s[4]?decodeURIComponent(s[4]):void 0,host:s[6]?decodeURIComponent(s[6]):s[6],port:s[8]?parseInt(s[8]):void 0,database:s[9]?decodeURIComponent(s[9]):s[9]},n=s[11];return n&&n.split("&").forEach(function(a){let A=a.indexOf("=");if(A!==1){let u=a.substring(A+1);u=u?decodeURIComponent(u):void 0,t[a.substring(0,A)]=u}}),this.parseOptionDataType(t)}},fe=vs;var Qs=class{constructor(e){typeof e=="string"&&(e=fe.parse(e),e.acquireTimeout&&(e.acquireTimeout=parseInt(e.acquireTimeout)),e.connectionLimit&&(e.connectionLimit=parseInt(e.connectionLimit)),e.idleTimeout&&(e.idleTimeout=parseInt(e.idleTimeout)),e.leakDetectionTimeout&&(e.leakDetectionTimeout=parseInt(e.leakDetectionTimeout)),e.initializationTimeout&&(e.initializationTimeout=parseInt(e.initializationTimeout)),e.minDelayValidation&&(e.minDelayValidation=parseInt(e.minDelayValidation)),e.minimumIdle&&(e.minimumIdle=parseInt(e.minimumIdle)),e.noControlAfterUse&&(e.noControlAfterUse=e.noControlAfterUse==="true"),e.resetAfterUse&&(e.resetAfterUse=e.resetAfterUse==="true"),e.pingTimeout&&(e.pingTimeout=parseInt(e.pingTimeout))),this.acquireTimeout=e.acquireTimeout===void 0?1e4:Number(e.acquireTimeout),this.connectionLimit=e.connectionLimit===void 0?10:Number(e.connectionLimit),this.idleTimeout=e.idleTimeout===void 0?1800:Number(e.idleTimeout),this.leakDetectionTimeout=Number(e.leakDetectionTimeout)||0,this.initializationTimeout=e.initializationTimeout===void 0?Math.max(100,this.acquireTimeout-100):Number(e.initializationTimeout),this.minDelayValidation=e.minDelayValidation===void 0?500:Number(e.minDelayValidation),this.minimumIdle=e.minimumIdle===void 0?this.connectionLimit:Math.min(Number(e.minimumIdle),this.connectionLimit),this.noControlAfterUse=!!e.noControlAfterUse||!1,this.resetAfterUse=!!e.resetAfterUse||!1,this.pingTimeout=Number(e.pingTimeout)||250,this.connOptions=new fe(e),this.acquireTimeout>0&&this.connOptions.connectTimeout>this.acquireTimeout&&(this.connOptions.connectTimeout=this.acquireTimeout)}},jt=Qs;var V_=require("node:events");var x_=require("node:events"),Wi=m(require("denque"),1);var Kr=m(require("iconv-lite"),1);var $t="0123456789ABCDEF".split("");function ne(E,e,s,t,n){let o=[];if(!e)return"";s==null&&(s=0),t==null&&(t=e.length);let a=new Array(16);a[8]=" ";let A=n!==void 0,u=s||0,h=Math.min(A?E.debugLen-n.length:E.debugLen,t-u),c=t-u>h,R,I=0,S=0;if(o.push(`+--------------------------------------------------+ | 0 1 2 3 4 5 6 7 8 9 a b c d e f | +--------------------------------------------------+------------------+ `),A)for(;S>>4],$t[R&15]," "),a[I++]=R>31&&R<127?String.fromCharCode(R):".",I===8&&o.push(" ");for(S=u;S>>4],$t[R&15]," "),a[I++]=R>31&&R<127?String.fromCharCode(R):".",I===8&&o.push(" "),I===16&&(o.push("| ",a.join(""),` | `),I=0),S++;let C=I;if(C>0){if(C<8){for(;C<8;C++)o.push(" "),a[I++]=" ";o.push(" ")}for(;C<16;C++)o.push(" "),a[I++]=" ";o.push("| ",a.join(""),c?` |... `:` | `)}else c&&(o[o.length-1]=` |... `);return o.push(`+--------------------------------------------------+------------------+ `),o.join("")}function vr(E){return Array.from(E,e=>("0"+(e&255).toString(16)).slice(-2)).join("")}function Zt(E,e,s){if(!s||s==="")throw f("Cannot escape empty ID value",N.ER_NULL_ESCAPEID,e,"0A000");if(s.includes("\0"))throw f("Cannot escape ID with null character (u0000)",N.ER_NULL_CHAR_ESCAPEID,e,"0A000");return"`"+s.replace(/`/g,"``")+"`"}function Ot(E,e,s){if(s==null)return"NULL";switch(typeof s){case"boolean":return s?"true":"false";case"bigint":case"number":return`${s}`;case"object":if(Object.prototype.toString.call(s)==="[object Date]")return G.getFixedFormatDate(s);if(Buffer.isBuffer(s)){let t;return Buffer.isEncoding(e.collation.charset)?t=s.toString(e.collation.charset,0,s.length):t=Kr.default.decode(s,e.collation.charset),"_binary'"+Tt(t)+"'"}else{if(typeof s.toSqlString=="function")return"'"+Tt(String(s.toSqlString()))+"'";if(Array.isArray(s)){let t=E.arrayParenthesis?"(":"";for(let n=0;n{let e=0,s="",t;for(;t=Yr.exec(E);)s+=E.substring(e,t.index),s+=ho[t[0]],e=Yr.lastIndex;return e===0?E:(e0}readInt8(){let e=this.buf[this.pos++];return e|(e&128)*33554430}readUInt8(){return this.buf[this.pos++]}readInt16(){this.pos+=2;let e=this.buf[this.pos-2],s=this.buf[this.pos-1],t=e+(s<<8);return t|(t&32768)*131070}readUInt16(){return this.pos+=2,this.buf[this.pos-2]+(this.buf[this.pos-1]<<8)}readInt24(){let e=this.buf[this.pos],s=this.buf[this.pos+2],t=e+(this.buf[this.pos+1]<<8)+(s<<16);return this.pos+=3,t|(t&8388608)*510}readUInt24(){return this.pos+=3,this.buf[this.pos-3]+(this.buf[this.pos-2]<<8)+(this.buf[this.pos-1]<<16)}readUInt32(){return this.pos+=4,this.buf[this.pos-4]+(this.buf[this.pos-3]<<8)+(this.buf[this.pos-2]<<16)+this.buf[this.pos-1]*16777216}readInt32(){return this.pos+=4,this.buf[this.pos-4]+(this.buf[this.pos-3]<<8)+(this.buf[this.pos-2]<<16)+(this.buf[this.pos-1]<<24)}readBigInt64(){let e=this.buf.readBigInt64LE(this.pos);return this.pos+=8,e}readBigUInt64(){let e=this.buf.readBigUInt64LE(this.pos);return this.pos+=8,e}readMetadataLength(){let e=this.buf[this.pos++];return e<251?e:this.readUInt16()}readUnsignedLength(){let e=this.buf[this.pos++];if(e<251)return e;switch(e){case 251:return null;case 252:return this.pos+=2,this.buf[this.pos-2]+(this.buf[this.pos-1]<<8);case 253:return this.pos+=3,this.buf[this.pos-3]+(this.buf[this.pos-2]<<8)+(this.buf[this.pos-1]<<16);case 254:return Number(this.readBigInt64())}}readBuffer(e){return this.pos+=e,this.buf.subarray(this.pos-e,this.pos)}readBufferLengthEncodedCopy(){let e=this.readUnsignedLength();return e===null?null:(this.pos+=e,Buffer.from(this.buf.subarray(this.pos-e,this.pos)))}readBufferRemaining(){let e=this.buf.subarray(this.pos,this.end);return this.pos=this.end,e}readBufferLengthEncoded(){let e=this.readUnsignedLength();return e===null?null:(this.pos+=e,this.buf.subarray(this.pos-e,this.pos))}readStringNullEnded(){let e=this.pos,s=0;for(;this.remaining()>0&&this.buf[this.pos++]!==0;)s++;return this.buf.toString(void 0,e,e+s)}readInsertId(){let e=this.buf[this.pos++];if(e<251)return BigInt(e);switch(e){case 252:return this.pos+=2,BigInt(this.buf[this.pos-2]+(this.buf[this.pos-1]<<8));case 253:return this.pos+=3,BigInt(this.buf[this.pos-3]+(this.buf[this.pos-2]<<8)+(this.buf[this.pos-1]<<16));case 254:return this.readBigInt64()}}readAsciiStringLengthEncoded(){let e=this.readUnsignedLength();return e===null?null:(this.pos+=e,this.buf.toString("ascii",this.pos-e,this.pos))}readStringLengthEncoded(){throw new Error("code is normally superseded by Node encoder or Iconv depending on charset used")}readBigIntLengthEncoded(){let e=this.buf[this.pos++];return e<16?BigInt(this._atoi(e)):e===251?null:this.readBigIntFromLen(e)}readBigIntFromLen(e){let s=0n,t=!1,n=this.pos;for(e>0&&this.buf[n]===45&&(t=!0,n++);n0&&(t=this.readInt16(),s>2&&(n=this.readUInt8()-1,s>3&&(o=this.readUInt8()))),t===0&&n===0&&o===0?e.dateStrings?"0000-00-00":null:e.dateStrings?`${z(t,4)}-${z(n+1,2)}-${z(o,2)}`:new Date(t,n,o)}readDateTime(){let e=this.buf[this.pos++];if(e===251)return null;this.pos+=e;let s=this.buf.toString("ascii",this.pos-e,this.pos);return s.startsWith("0000-00-00 00:00:00")?null:new Date(s)}readBinaryDateTime(){let e=this.buf[this.pos++],s=0,t=0,n=0,o=0,a=0,A=0,u=0;return e>0&&(s=this.readInt16(),e>2&&(t=this.readUInt8(),e>3&&(n=this.readUInt8(),e>4&&(o=this.readUInt8(),a=this.readUInt8(),A=this.readUInt8(),e>7&&(u=this.readUInt32()))))),s===0&&t===0&&n===0&&o===0&&a===0&&A===0&&u===0?null:new Date(s,t-1,n,o,a,A,u/1e3)}readBinaryDateTimeAsString(e){let s=this.buf[this.pos++],t=0,n=0,o=0,a=0,A=0,u=0,h=0;return s>0&&(t=this.readInt16(),s>2&&(n=this.readUInt8(),s>3&&(o=this.readUInt8(),s>4&&(a=this.readUInt8(),A=this.readUInt8(),u=this.readUInt8(),s>7&&(h=this.readUInt32()))))),t===0&&n===0&&o===0&&a===0&&A===0&&u===0&&h===0?"0000-00-00 00:00:00"+(e>0?".000000".substring(0,e+1):""):z(t,4)+"-"+z(n,2)+"-"+z(o,2)+" "+z(a,2)+":"+z(A,2)+":"+z(u,2)+(h>0?e>0?"."+z(h,6).substring(0,e):"."+z(h,6):e>0?"."+z(h,6).substring(0,e):"")}readBinaryTime(){let e=this.buf[this.pos++],s=!1,t=0,n=0,o=0,a=0;e>0&&(s=this.buf[this.pos++]===1,t=this.readUInt32()*24+this.readUInt8(),n=this.readUInt8(),o=this.readUInt8(),e>8&&(a=this.readUInt32()));let A=z(t,2)+":"+z(n,2)+":"+z(o,2);return a>0&&(A+="."+z(a,6)),s?"-"+A:A}readFloat(){let e=this.buf.readFloatLE(this.pos);return this.pos+=4,e}readDouble(){let e=this.buf.readDoubleLE(this.pos);return this.pos+=8,e}readIntLengthEncoded(){let e=this.buf[this.pos++];return e===251?null:this._atoi(e)}_atoi(e){let s=0,t=!1,n=this.pos;for(e>0&&this.buf[n]===45&&(t=!0,n++);n{let s=E.toString();for(;s.length>8,this.header[2]=this.packetLen>>16,this.header[3]=this.sequenceNo,e&&this.opts.logger.network(`<== conn:${this.info.threadId?this.info.threadId:-1} ${s?s.onPacketReceive?s.constructor.name+"."+s.onPacketReceive.name:s.constructor.name:"no command"} (${e.pos},${e.end}) ${ne(this.opts,e.buf,e.pos,e.end,this.header)}`),!s){this.unexpectedPacket(e);return}s.sequenceNo=this.sequenceNo,s.onPacketReceive(e,this.out,this.opts,this.info),s.onPacketReceive||(this._cmd=null,this.receiveQueue.shift())}receivePacketBasic(e){let s=this._cmd;if((!s||!s.onPacketReceive)&&(s=this.currentCmd(),!s)){this.unexpectedPacket(e);return}s.sequenceNo=this.sequenceNo,s.onPacketReceive(e,this.out,this.opts,this.info),s.onPacketReceive||(this._cmd=null,this.receiveQueue.shift())}resetHeader(){this.remainingLen=null,this.headerLen=0}currentCmd(){let e;for(;e=this.receiveQueue.peek();){if(e.onPacketReceive)return this._cmd=e,e;this.receiveQueue.shift()}return this._cmd=null,null}onData(e){let s=0,t,n=e.length;do{if(this.remainingLen)t=this.remainingLen;else if(this.headerLen===0&&n-s>=4)this.packetLen=e[s]+(e[s+1]<<8)+(e[s+2]<<16),this.sequenceNo=e[s+3],s+=4,t=this.packetLen;else for(t=null;n-s>0;)if(this.header[this.headerLen++]=e[s++],this.headerLen===4){this.packetLen=this.header[0]+(this.header[1]<<8)+(this.header[2]<<16),this.sequenceNo=this.header[3],t=this.packetLen;break}if(t)if(n-s>=t){if(s+=t,this.parts){if(this.parts.push(e.subarray(s-t,s)),this.partsTotalLen+=t,this.packetLen<16777215){let o=Buffer.concat(this.parts,this.partsTotalLen);this.parts=null,this.receivePacket(this.packet.update(o,0,this.partsTotalLen))}}else if(this.packetLen<16777215){this.receivePacket(this.packet.update(e,s-t,s));let o=this._cmd,a=this.packet;for(;s+4=this.packetLen)if(s+=this.packetLen,this.packetLen<16777215)!this._debug&&o&&o.onPacketReceive&&e[s-this.packetLen]<254?(o.sequenceNo=this.sequenceNo,o.onPacketReceive(a.update(e,s-this.packetLen,s),this.out,this.opts,this.info)):(this.receivePacket(a.update(e,s-this.packetLen,s)),o=this._cmd);else{this.parts=[e.subarray(s-this.packetLen,s)],this.partsTotalLen=this.packetLen;break}else{let A=e.subarray(s,n);this.parts?(this.parts.push(A),this.partsTotalLen+=n-s):(this.parts=[A],this.partsTotalLen=n-s),this.remainingLen=this.packetLen-(n-s);return}}else this.parts=[e.subarray(s-t,s)],this.partsTotalLen=t;this.resetHeader()}else{let o=e.subarray(s,n);this.parts?(this.parts.push(o),this.partsTotalLen+=n-s):(this.parts=[o],this.partsTotalLen=n-s),this.remainingLen=t-(n-s);return}else if(t===0&&this.parts){this.parts.push(e.subarray(s-t,s));let o=Buffer.concat(this.parts,this.partsTotalLen);this.receivePacket(this.packet.update(o,0,this.partsTotalLen)),this.parts=null,this.resetHeader()}}while(sE>=161&&E<=254,length:(E,e,s)=>{if(e+1>=s)return 0;let t=E[e+1];return t>=64&&t<=126||t>=161&&t<=254?2:0}},lo={isHead:E=>E>=129&&E<=254,length:(E,e,s)=>{if(e+1>=s)return 0;let t=E[e+1];return t>=64&&t<=126||t>=128&&t<=254?2:0}},Jr={isHead:E=>E>=129&&E<=159||E>=224&&E<=252,length:(E,e,s)=>{if(e+1>=s)return 0;let t=E[e+1];return t>=64&&t<=126||t>=128&&t<=252?2:0}},No=Jr,$r=E=>E>=129&&E<=254,Io=E=>E>=64&&E<=126||E>=128&&E<=254,Zr=E=>E>=48&&E<=57,Ro={isHead:$r,length:(E,e,s)=>e+1>=s?0:Io(E[e+1])?2:e+3So[E]||null;var le=39,dt=34,pt=0,Ne=92,Et=256,es=16384,ts=131072,ss=1048576,Ce=16777219,e_=/[\000\032"'\\\n\r\t]/g,Zs=class{constructor(e,s){this.opts=e,this.info=s,this.pos=4,this.markPos=-1,this.bufContainDataAfterMark=!1,this.cmdLength=0,this.buf=Buffer.allocUnsafe(Et),this.maxAllowedPacket=e.maxAllowedPacket||16777216,this.maxPacketLength=Math.min(Ce,this.maxAllowedPacket+4),this.changeEncoding(this.opts.collation?this.opts.collation:P.fromIndex(224)),this.changeDebug(this.opts.debug),this.opts.on("collation",this.changeEncoding.bind(this)),this.opts.on("debug",this.changeDebug.bind(this))}changeEncoding(e){this.encoding=e.charset,this.encoding==="utf8"?(this.writeString=this.writeDefaultBufferString,this.encodeString=this.encodeNodeString,this.writeLengthEncodedString=this.writeDefaultBufferLengthEncodedString,this.writeStringEscapeQuote=this.writeUtf8StringEscapeQuote):Buffer.isEncoding(this.encoding)?(this.writeString=this.writeDefaultBufferString,this.encodeString=this.encodeNodeString,this.writeLengthEncodedString=this.writeDefaultBufferLengthEncodedString,this.writeStringEscapeQuote=this.writeDefaultStringEscapeQuote):(this.writeString=this.writeDefaultIconvString,this.encodeString=this.encodeIconvString,this.writeLengthEncodedString=this.writeDefaultIconvLengthEncodedString,this.writeStringEscapeQuote=this.writeDefaultStringEscapeQuote);let s=zr(this.encoding);this.writeBufferEscape=s?this.writeBufferEscapeMb.bind(this,s):this.writeBufferEscapeFast}changeDebug(e){this.debug=e,this.flushBuffer=e?this.flushBufferDebug:this.flushBufferBasic,this.fastFlush=e?this.fastFlushDebug:this.fastFlushBasic}setStream(e){this.stream=e}growBuffer(e){let s;if(e+this.poss&&this.markPos!==-1)return this.flushBufferStopAtMark(),e+this.pos<=this.buf.length?void 0:this.growBuffer(e);let t=Buffer.allocUnsafe(s);this.buf.copy(t,0,0,this.pos),this.buf=t}mark(){this.markPos=this.pos}isMarked(){return this.markPos!==-1}hasFlushed(){return this.cmd.sequenceNo!==-1}hasDataAfterMark(){return this.bufContainDataAfterMark}bufIsAfterMaxPacketLength(){return this.pos>this.maxPacketLength}resetMark(){if(this.pos=this.markPos,this.markPos=-1,this.bufContainDataAfterMark){let e=Buffer.allocUnsafe(this.pos-4);return this.buf.copy(e,0,4,this.pos),this.cmd.sequenceNo=-1,this.cmd.compressSequenceNo=-1,this.bufContainDataAfterMark=!1,e}return null}flush(){this.flushBuffer(!0,0),this.buf=Buffer.allocUnsafe(Et),this.cmd.sequenceNo=-1,this.cmd.compressSequenceNo=-1,this.cmdLength=0,this.markPos=-1}flushPacket(){this.flushBuffer(!1,0),this.buf=Buffer.allocUnsafe(Et),this.cmdLength=0,this.markPos=-1}startPacket(e){this.cmd=e,this.pos=4}writeInt8(e){if(this.pos+1>=this.buf.length){let s=Buffer.allocUnsafe(1);s[0]=e,this.writeBuffer(s,0,1);return}this.buf[this.pos++]=e}writeInt16(e){if(this.pos+2>=this.buf.length){let s=Buffer.allocUnsafe(2);s[0]=e,s[1]=e>>>8,this.writeBuffer(s,0,2);return}this.buf[this.pos]=e,this.buf[this.pos+1]=e>>8,this.pos+=2}writeInt16AtPos(e){this.buf[e]=this.pos-e-2,this.buf[e+1]=this.pos-e-2>>8}writeInt24(e){if(this.pos+3>=this.buf.length){let s=Buffer.allocUnsafe(3);s[0]=e,s[1]=e>>8,s[2]=e>>16,this.writeBuffer(s,0,3);return}this.buf[this.pos]=e,this.buf[this.pos+1]=e>>8,this.buf[this.pos+2]=e>>16,this.pos+=3}writeInt32(e){if(this.pos+4>=this.buf.length){let s=Buffer.allocUnsafe(4);s.writeInt32LE(e,0),this.writeBuffer(s,0,4);return}this.buf[this.pos]=e,this.buf[this.pos+1]=e>>8,this.buf[this.pos+2]=e>>16,this.buf[this.pos+3]=e>>24,this.pos+=4}writeBigInt(e){if(this.pos+8>=this.buf.length){let s=Buffer.allocUnsafe(8);s.writeBigInt64LE(e,0),this.writeBuffer(s,0,8);return}this.buf.writeBigInt64LE(e,this.pos),this.pos+=8}writeDouble(e){if(this.pos+8>=this.buf.length){let s=Buffer.allocUnsafe(8);s.writeDoubleLE(e,0),this.writeBuffer(s,0,8);return}this.buf.writeDoubleLE(e,this.pos),this.pos+=8}writeLengthCoded(e){if(e<251){this.writeInt8(e);return}e<65536?(this.writeInt8(252),this.writeInt16(e)):e<16777216?(this.writeInt8(253),this.writeInt24(e)):(this.writeInt8(254),this.writeBigInt(BigInt(e)))}writeBuffer(e,s,t){if(t>this.buf.length-this.pos&&(this.buf.length!==Ce&&this.growBuffer(t),t>this.buf.length-this.pos&&(this.markPos!==-1&&(this.growBuffer(t),this.markPos!==-1&&this.flushBufferStopAtMark()),t>this.buf.length-this.pos))){let n=t;for(;;){let o=Math.min(Ce-this.pos,n);if(e.copy(this.buf,this.pos,s,s+o),n-=o,s+=o,this.pos+=o,n===0)return;this.flushBuffer(!1,n)}}if(t>50)e.copy(this.buf,this.pos,s,s+t),this.pos+=t;else for(let n=0;n=this.buf.length-this.pos){let t=Buffer.from(e,"ascii");this.writeBuffer(t,0,t.length);return}for(let t=0;t=this.buf.length-this.pos){let o=Buffer.from(e,"utf8");this.writeInt8(le),this.writeBufferEscape(o),this.writeInt8(le);return}let t=0,n;for(this.buf[this.pos++]=le;t>6,this.buf[this.pos++]=128|n&63;else if(n>=55296&&n<57344)if(n<56320)if(t+1>s)this.buf[this.pos++]=63;else{let o=e.charCodeAt(t);if(o>=56320&&o<57344){let a=(n<<10)+o+-56613888;this.buf[this.pos++]=240|a>>18,this.buf[this.pos++]=128|a>>12&63,this.buf[this.pos++]=128|a>>6&63,this.buf[this.pos++]=128|a&63,t++}else this.buf[this.pos++]=63}else this.buf[this.pos++]=63;else this.buf[this.pos++]=224|n>>12,this.buf[this.pos++]=128|n>>6&63,this.buf[this.pos++]=128|n&63;this.buf[this.pos++]=le}encodeIconvString(e){return is.default.encode(e,this.encoding)}encodeNodeString(e){return Buffer.from(e,this.encoding)}writeDefaultBufferString(e){if(e.length*3this.buf.length-this.pos&&(this.buf.lengththis.buf.length-this.pos)){let t=Buffer.from(e,this.encoding);this.writeBuffer(t,0,t.length);return}this.pos+=this.buf.write(e,this.pos,this.encoding)}writeDefaultBufferLengthEncodedString(e){let s=Buffer.byteLength(e,this.encoding);if(this.writeLengthCoded(s),s>this.buf.length-this.pos&&(this.buf.lengththis.buf.length-this.pos)){let t=Buffer.from(e,this.encoding);this.writeBuffer(t,0,t.length);return}this.pos+=this.buf.write(e,this.pos,this.encoding)}writeDefaultIconvString(e){let s=is.default.encode(e,this.encoding);this.writeBuffer(s,0,s.length)}writeDefaultIconvLengthEncodedString(e){let s=is.default.encode(e,this.encoding);this.writeLengthCoded(s.length),this.writeBuffer(s,0,s.length)}writeDefaultStringEscapeQuote(e){this.writeInt8(le);let s,t=0;for(;(s=e_.exec(e))!==null;)this.writeString(e.slice(t,s.index)),this.writeInt8(Ne),this.writeInt8(s[0].charCodeAt(0)),t=e_.lastIndex;if(t===0){this.writeString(e),this.writeInt8(le);return}tthis.buf.length-this.pos){let c=Buffer.allocUnsafe(h+1);if(c[0]=h,c[1]=s,c[2]=s>>>8,c[3]=t,c[4]=n,c[5]=o,c[6]=a,c[7]=A,u!==0){let R=u*1e3;c[8]=R,c[9]=R>>>8,c[10]=R>>>16,c[11]=R>>>24}this.writeBuffer(c,0,h+1);return}if(this.buf[this.pos]=h,this.buf[this.pos+1]=s,this.buf[this.pos+2]=s>>>8,this.buf[this.pos+3]=t,this.buf[this.pos+4]=n,this.buf[this.pos+5]=o,this.buf[this.pos+6]=a,this.buf[this.pos+7]=A,u!==0){let c=u*1e3;this.buf[this.pos+8]=c,this.buf[this.pos+9]=c>>>8,this.buf[this.pos+10]=c>>>16,this.buf[this.pos+11]=c>>>24}this.pos+=h+1}writeBufferEscape(e){this.writeBufferEscapeFast(e)}writeBufferEscapeFast(e){let s=e.length;if(s*2>this.buf.length-this.pos&&(this.buf.length!==Ce&&this.growBuffer(s*2),s*2>this.buf.length-this.pos)){for(let t=0;t=this.buf.length&&this.flushBuffer(!1,(s-t)*2),this.buf[this.pos++]=Ne}this.pos>=this.buf.length&&this.flushBuffer(!1,(s-t)*2),this.buf[this.pos++]=e[t]}return}for(let t=0;tthis.buf.length-this.pos&&this.buf.length!==Ce&&this.growBuffer(t*2);let n=0;for(;n=2){for(let A=0;A=this.buf.length&&this.flushBuffer(!1,(t-n)*2),this.buf[this.pos++]=s[n+A];n+=a;continue}this.pos>=this.buf.length&&this.flushBuffer(!1,(t-n)*2),this.buf[this.pos++]=Ne,this.pos>=this.buf.length&&this.flushBuffer(!1,(t-n)*2),this.buf[this.pos++]=o,n++;continue}(o===le||o===Ne||o===dt||o===pt)&&(this.pos>=this.buf.length&&this.flushBuffer(!1,(t-n)*2),this.buf[this.pos++]=Ne),this.pos>=this.buf.length&&this.flushBuffer(!1,(t-n)*2),this.buf[this.pos++]=o,n++}}checkMaxAllowedLength(e,s){return this.opts.maxAllowedPacket&&this.cmdLength+e>=this.maxAllowedPacket?f(`query size (${this.cmdLength+e}) is >= to max_allowed_packet (${this.maxAllowedPacket})`,N.ER_MAX_ALLOWED_PACKET,s):null}isEmpty(){return this.pos<=4}flushBufferDebug(e,s){this.pos>4&&(this.buf[0]=this.pos-4,this.buf[1]=this.pos-4>>>8,this.buf[2]=this.pos-4>>>16,this.buf[3]=++this.cmd.sequenceNo,this.stream.writeBuf(this.buf.subarray(0,this.pos),this.cmd),this.stream.flush(!0,this.cmd),this.cmdLength+=this.pos-4,this.opts.logger.network(`==> conn:${this.info.threadId?this.info.threadId:-1} ${this.cmd.constructor.name+"(0,"+this.pos+")"} ${ne(this.opts,this.buf,0,this.pos)}`),e&&this.pos===Ce&&this.writeEmptyPacket(),this.buf=this.createBufferWithMinSize(s),this.pos=4)}flushBufferStopAtMark(){let e=this.pos;this.pos=this.markPos;let s=Buffer.allocUnsafe(Math.max(Et,e+4-this.pos));this.buf.copy(s,4,this.markPos,e),this.flushBuffer(!0,e-this.pos),this.cmdLength=0,this.buf=s,this.pos=4+e-this.markPos,this.markPos=-1,this.bufContainDataAfterMark=!0}flushBufferBasic(e,s){this.buf[0]=this.pos-4,this.buf[1]=this.pos-4>>>8,this.buf[2]=this.pos-4>>>16,this.buf[3]=++this.cmd.sequenceNo,this.stream.writeBuf(this.buf.subarray(0,this.pos),this.cmd),this.stream.flush(!0,this.cmd),this.cmdLength+=this.pos-4,e&&this.pos===Ce&&this.writeEmptyPacket(),this.buf=this.createBufferWithMinSize(s),this.pos=4}createBufferWithMinSize(e){let s;return e+4 conn:${this.info.threadId?this.info.threadId:-1} ${e.constructor.name+"(0,"+s.length+")"} ${ne(this.opts,s,0,s.length)}`),this.cmdLength=0,this.markPos=-1}fastFlushBasic(e,s){this.stream.writeBuf(s,e),this.stream.flush(!0,e),this.cmdLength=0,this.markPos=-1}writeEmptyPacket(){let e=Buffer.from([0,0,0,++this.cmd.sequenceNo]);this.debug&&this.opts.logger.network(`==> conn:${this.info.threadId?this.info.threadId:-1} ${this.cmd.constructor.name}(0,4) ${ne(this.opts,e,0,4)}`),this.stream.writeBuf(e,this.cmd),this.stream.flush(!0,this.cmd),this.cmdLength=0}},t_=Zs;var s_=m(require("node:zlib"),1);var Js=class{constructor(e,s,t,n){this.reader=e,this.receiveQueue=s,this.info=n,this.opts=t,this.header=Buffer.allocUnsafe(7),this.headerLen=0,this.compressPacketLen=null,this.packetLen=null,this.remainingLen=null,this.parts=null,this.partsTotalLen=0}receivePacket(e){let s=this.currentCmd();if(this.opts.debugCompress&&this.opts.logger.network(`<== conn:${this.info.threadId?this.info.threadId:-1} ${s?s.onPacketReceive?s.constructor.name+"."+s.onPacketReceive.name:s.constructor.name:"no command"} (compress) ${ne(this.opts,e,0,e.length,this.header)}`),s&&(s.compressSequenceNo=this.header[3]),(this.header[4]|this.header[5]<<8|this.header[6]<<16)===0)this.reader.onData(e);else{let n=s_.default.inflateSync(e);this.reader.onData(n)}}currentCmd(){let e;for(;e=this.receiveQueue.peek();){if(e.onPacketReceive)return e;this.receiveQueue.shift()}return null}resetHeader(){this.remainingLen=null,this.headerLen=0}onData(e){let s=0,t,n=e.length;do{if(this.remainingLen)t=this.remainingLen;else if(this.headerLen===0&&n-s>=7)this.header[0]=e[s],this.header[1]=e[s+1],this.header[2]=e[s+2],this.header[3]=e[s+3],this.header[4]=e[s+4],this.header[5]=e[s+5],this.header[6]=e[s+6],this.headerLen=7,s+=7,this.compressPacketLen=this.header[0]+(this.header[1]<<8)+(this.header[2]<<16),this.packetLen=this.header[4]|this.header[5]<<8|this.header[6]<<16,this.packetLen===0&&(this.packetLen=this.compressPacketLen),t=this.compressPacketLen;else for(t=null;n-s>0;)if(this.header[this.headerLen++]=e[s++],this.headerLen===7){this.compressPacketLen=this.header[0]+(this.header[1]<<8)+(this.header[2]<<16),this.packetLen=this.header[4]|this.header[5]<<8|this.header[6]<<16,this.packetLen===0&&(this.packetLen=this.compressPacketLen),t=this.compressPacketLen;break}if(t)if(n-s>=t){let o=e.subarray(s,s+t);if(s+=t,this.parts){if(this.parts.push(o),this.partsTotalLen+=t,this.compressPacketLen<16777215){let a=Buffer.concat(this.parts,this.partsTotalLen);this.parts=null,this.receivePacket(a)}}else this.compressPacketLen<16777215?this.receivePacket(o):(this.parts=[o],this.partsTotalLen=t);this.resetHeader()}else{let o=e.subarray(s,n);this.parts?(this.parts.push(o),this.partsTotalLen+=n-s):(this.parts=[o],this.partsTotalLen=n-s),this.remainingLen=t-(n-s);return}}while(s{e.write(n)}}growBuffer(e){let s;e+this.pos<_s?s=_s:e+this.posthis.buf.length-this.pos&&(this.buf.length!==Ut&&this.growBuffer(n),n>this.buf.length-this.pos)){let o=n;for(;;){let a=Math.min(Ut-this.pos,o);if(e.copy(this.buf,this.pos,t,t+a),o-=a,t+=a,this.pos+=a,o===0)return;this.flush(!1,s,o)}}e.copy(this.buf,this.pos,t,t+n),this.pos+=n}flush(e,s,t){if(this.pos<1536)this.buf[0]=this.pos-7,this.buf[1]=this.pos-7>>>8,this.buf[2]=this.pos-7>>>16,this.buf[3]=++s.compressSequenceNo,this.buf[4]=0,this.buf[5]=0,this.buf[6]=0,this.opts.debugCompress&&this.opts.logger.network(`==> conn:${this.info.threadId?this.info.threadId:-1} ${s?s.constructor.name+"(0,"+this.pos+")":"unknown"} (compress) ${ne(this.opts,this.buf,0,this.pos)}`),this.writer(this.buf.subarray(0,this.pos));else{let n=r_.default.deflateSync(this.buf.subarray(7,this.pos)),o=n.length;this.header[0]=o,this.header[1]=o>>>8,this.header[2]=o>>>16,this.header[3]=++s.compressSequenceNo,this.header[4]=this.pos-7,this.header[5]=this.pos-7>>>8,this.header[6]=this.pos-7>>>16,this.opts.debugCompress&&this.opts.logger.network(`==> conn:${this.info.threadId?this.info.threadId:-1} ${s?s.constructor.name+"(0,"+this.pos+"=>"+o+")":"unknown"} (compress) ${ne(this.opts,n,0,o,this.header)}`),this.writer(this.header),this.writer(n),e&&o===Ut&&this.writeEmptyPacket(s),this.header=Buffer.allocUnsafe(7)}this.buf=t?E.allocateBuffer(t):Buffer.allocUnsafe(rs),this.pos=7}static allocateBuffer(e){return e+4 conn:${this.info.threadId?this.info.threadId:-1} ${e?e.constructor.name+"(0,"+this.pos+")":"unknown"} (compress) ${ne(this.opts,s,0,7)}`),this.writer(s)}},__=zs;var ei=class{#e;constructor(e,s){this.threadId=-1,this.status=null,this.serverVersion=null,this.serverCapabilities=null,this.database=e.database,this.port=e.port,this.#e=s,this.redirectRequest=null}hasMinVersion(e,s,t){if(!this.serverVersion)throw new Error("cannot know if server version until connection is established");if(!e)throw new Error("a major version must be set");s||(s=0),t||(t=0);let n=this.serverVersion;return n.major>e||n.major===e&&n.minor>s||n.major===e&&n.minor===s&&n.patch>=t}redirect(e,s){return this.#e(e,s)}isMariaDB(){if(!this.serverVersion)throw new Error("cannot know if server is MariaDB until connection is established");return this.serverVersion.mariaDb}static parseVersionString(e){let s,t=0,n=0,o=0;for(;t57){switch(n){case 0:e.serverVersion.major=o;break;case 1:e.serverVersion.minor=o;break;case 2:e.serverVersion.patch=o;return}n++,o=0}else o=o*10+s-48;n===2&&(e.serverVersion.patch=o)}},Lt=ei;var y_=m(require("node:tls"),1);var ti=class extends re{constructor(e,s,t){super(e,s,t),this.onPacketReceive=s}isMitmProof(){return!1}requireSecure(){return!1}isSecureConnection(e){return!!e.ssl||!!e.socketPath&&process.platform!=="win32"}hash(e){return null}},ee=ti;var si=class{constructor(e,s){e.skip(1),s.serverVersion={},s.serverVersion.raw=e.readStringNullEnded(),s.threadId=e.readUInt32();let t=e.readBuffer(8);e.skip(1);let n=BigInt(e.readUInt16());s.collation=P.fromIndex(e.readUInt8()),s.status=e.readUInt16(),n+=BigInt(e.readUInt16())<<16n;let o=0;if(n&Re?o=Math.max(12,e.readUInt8()-9):e.skip(1),n<?e.skip(10):(e.skip(6),n+=BigInt(e.readUInt32())<<32n),n&Ge){let a=e.readBuffer(o);s.seed=Buffer.concat([t,a])}else s.seed=t;e.skip(1),s.serverCapabilities=n,s.serverVersion.raw.startsWith("5.5.5-")?(s.serverVersion.mariaDb=!0,s.serverVersion.raw=s.serverVersion.raw.substring(6)):s.serverVersion.mariaDb=s.serverVersion.raw.includes("MariaDB")||(n<)===0n,n&Re?this.pluginName=e.readStringNullEnded():this.pluginName="",Lt.parseVersionString(s)}},n_=si;function ii(E,e){let s=Ar|ur|hr|Ge|lr|Nr|Rr|tt|Bt|Gt|Re;E.foundRows&&(s|=Er),E.permitLocalInfile&&(s|=ar),E.multipleStatements&&(s|=cr),e.eofDeprecated=!E.keepEof&&(e.serverCapabilities&Cs)>0,e.eofDeprecated&&(s|=Cs),E.database&&e.serverCapabilities&qe&&(s|=qe),e.serverPermitSkipMeta=(e.serverCapabilities&Ts)>0,e.serverPermitSkipMeta&&(s|=Ts),E.compress&&(e.serverCapabilities&Nt?s|=Nt:E.compress=!1),E.bulk&&e.serverCapabilities&It&&(s|=It,s|=st),E.permitConnectionWhenExpired&&(s|=Ir),e.clientCapabilities=s&e.serverCapabilities}function ri(E,e,s,t){e.startPacket(E),e.writeInt32(Number(s.clientCapabilities&BigInt(4294967295))),e.writeInt32(1024*1024*1024),e.writeInt8(t.collation&&t.collation.index<=255?t.collation.index:224);for(let n=0;n<19;n++)e.writeInt8(0);s.serverCapabilities<?e.writeInt32(0):e.writeInt32(Number(s.clientCapabilities>>32n)),e.flushPacket()}var at=m(require("node:crypto"),1),_i=class E extends ee{constructor(e,s,t,n,o,a){super(n,a,o),this.pluginData=t,this.sequenceNo=e,this.compressSequenceNo=s}start(e,s,t){let n=this.pluginData.slice(0,20),o=E.encryptSha1Password(s.password,n);e.startPacket(this),o.length>0?(e.writeBuffer(o,0,o.length),e.flushPacket()):e.writeEmptyPacket(!0),this.emit("send_end")}static encryptSha1Password(e,s){if(!e)return Buffer.alloc(0);let t=at.default.createHash("sha1"),n=t.update(e,"utf8").digest();t=at.default.createHash("sha1");let o=t.update(n).digest();t=at.default.createHash("sha1"),t.update(s),t.update(o);let a=t.digest(),A=Buffer.allocUnsafe(a.length);for(let u=0;u{let a=this.getSocket();n.selfSignedCertificate=!a.authorized,n.tlsAuthorizationError=a.authorizationError;let A=a.getPeerCertificate(!1);if(n.tlsCert=A,n.tlsFingerprint=A?A.fingerprint256.replace(/:/gi,"").toLowerCase():null,n.requireValidCert&&n.selfSignedCertificate&&t.password&&!this.isMitmProof())return this.throwNewError(`Unsupported authentication plugin ${this.pluginName} with Self signed certificates. Either set 'ssl: { rejectUnauthorized: false }' (trust mode) or provide server certificate to client`,!0,n,"08000",N.ER_SELF_SIGNED_BAD_PLUGIN);E.send.call(this,this,s,t,o.pluginName,n)});else return this.throwNewError("Trying to connect with ssl, but ssl not enabled in the server",!0,n,"08S01",N.ER_SERVER_SSL_DISABLED);else E.send(this,s,t,o.pluginName,n);this.onPacketReceive=this.auth.handshakeResult.bind(this.auth)}isMitmProof(){return this.pluginName!=="mysql_clear_password"}requireSecure(){return this.pluginName==="mysql_clear_password"}hash(e){let s=ni.default.createHash("sha1"),t=s.update(e.password,"utf8").digest();return s=ni.default.createHash("sha1"),s.update(t).digest()}static send(e,s,t,n,o){s.startPacket(e),o.defaultPluginName=n;let a=Array.isArray(t.password)?t.password[0]:t.password,A,u;n==="mysql_clear_password"?(A=Buffer.from(a),u="mysql_clear_password"):(A=At.encryptSha1Password(a,o.seed),u="mysql_native_password"),s.writeInt32(Number(o.clientCapabilities&BigInt(4294967295))),s.writeInt32(1024*1024*1024),s.writeInt8(t.collation&&t.collation.index<=255?t.collation.index:224);for(let h=0;h<19;h++)s.writeInt8(0);if(s.writeInt32(Number(o.clientCapabilities>>32n)),s.writeString(t.user||""),s.writeInt8(0),o.serverCapabilities&Bt?(s.writeLengthCoded(A.length),s.writeBuffer(A,0,A.length)):o.serverCapabilities&Ge?(s.writeInt8(A.length),s.writeBuffer(A,0,A.length)):(s.writeBuffer(A,0,A.length),s.writeInt8(0)),o.clientCapabilities&qe&&(s.writeString(t.database),s.writeInt8(0),o.database=t.database),o.clientCapabilities&Re&&(s.writeString(u),s.writeInt8(0)),o.clientCapabilities&tt){s.writeInt8(252);let h=s.pos;s.writeInt16(0);let c=o.collation?o.collation.charset:"utf8";if(E.writeAttribute(s,"_client_name",c),E.writeAttribute(s,"MariaDB connector/Node",c),E.writeAttribute(s,"_client_version",c),E.writeAttribute(s,fo,c),this.host&&(E.writeAttribute(s,"_server_host",c),E.writeAttribute(s,this.host,c)),E.writeAttribute(s,"_os",c),E.writeAttribute(s,process.platform,c),E.writeAttribute(s,"_client_host",c),E.writeAttribute(s,E_.default.hostname(),c),E.writeAttribute(s,"_node_version",c),E.writeAttribute(s,process.versions.node,c),t.connectAttributes!==!0){let R=Object.keys(t.connectAttributes);for(let I=0;I=32;--t){for(s=0,n=t-32,o=t-12;n>8,e[n]-=s*256;e[n]+=s,e[t]=0}for(s=0,n=0;n<32;n++)e[n]+=s-(e[31]>>4)*ai[n],s=e[n]>>8,e[n]&=255;for(n=0;n<32;n++)e[n]-=s*ai[n];for(t=0;t<32;t++)e[t+1]+=e[t]>>8,E[t]=e[t]&255}function ui(E,e){let s=[O(),O(),O(),O()];Ze(s[0],h_),Ze(s[1],c_),Ze(s[2],li),oe(s[3],h_,c_),To(E,s,e)}function Ze(E,e){for(let s=0;s<16;s++)E[s]=e[s]|0}function oe(E,e,s){let t,n,o=0,a=0,A=0,u=0,h=0,c=0,R=0,I=0,S=0,C=0,d=0,b=0,g=0,U=0,M=0,B=0,F=0,se=0,ie=0,ae=0,ue=0,Ie=0,Te=0,Ue=0,Me=0,Ke=0,et=0,ht=0,bt=0,Rs=0,zi=0,H=s[0],y=s[1],k=s[2],x=s[3],V=s[4],W=s[5],Y=s[6],K=s[7],v=s[8],Q=s[9],q=s[10],X=s[11],j=s[12],$=s[13],Z=s[14],J=s[15];t=e[0],o+=t*H,a+=t*y,A+=t*k,u+=t*x,h+=t*V,c+=t*W,R+=t*Y,I+=t*K,S+=t*v,C+=t*Q,d+=t*q,b+=t*X,g+=t*j,U+=t*$,M+=t*Z,B+=t*J,t=e[1],a+=t*H,A+=t*y,u+=t*k,h+=t*x,c+=t*V,R+=t*W,I+=t*Y,S+=t*K,C+=t*v,d+=t*Q,b+=t*q,g+=t*X,U+=t*j,M+=t*$,B+=t*Z,F+=t*J,t=e[2],A+=t*H,u+=t*y,h+=t*k,c+=t*x,R+=t*V,I+=t*W,S+=t*Y,C+=t*K,d+=t*v,b+=t*Q,g+=t*q,U+=t*X,M+=t*j,B+=t*$,F+=t*Z,se+=t*J,t=e[3],u+=t*H,h+=t*y,c+=t*k,R+=t*x,I+=t*V,S+=t*W,C+=t*Y,d+=t*K,b+=t*v,g+=t*Q,U+=t*q,M+=t*X,B+=t*j,F+=t*$,se+=t*Z,ie+=t*J,t=e[4],h+=t*H,c+=t*y,R+=t*k,I+=t*x,S+=t*V,C+=t*W,d+=t*Y,b+=t*K,g+=t*v,U+=t*Q,M+=t*q,B+=t*X,F+=t*j,se+=t*$,ie+=t*Z,ae+=t*J,t=e[5],c+=t*H,R+=t*y,I+=t*k,S+=t*x,C+=t*V,d+=t*W,b+=t*Y,g+=t*K,U+=t*v,M+=t*Q,B+=t*q,F+=t*X,se+=t*j,ie+=t*$,ae+=t*Z,ue+=t*J,t=e[6],R+=t*H,I+=t*y,S+=t*k,C+=t*x,d+=t*V,b+=t*W,g+=t*Y,U+=t*K,M+=t*v,B+=t*Q,F+=t*q,se+=t*X,ie+=t*j,ae+=t*$,ue+=t*Z,Ie+=t*J,t=e[7],I+=t*H,S+=t*y,C+=t*k,d+=t*x,b+=t*V,g+=t*W,U+=t*Y,M+=t*K,B+=t*v,F+=t*Q,se+=t*q,ie+=t*X,ae+=t*j,ue+=t*$,Ie+=t*Z,Te+=t*J,t=e[8],S+=t*H,C+=t*y,d+=t*k,b+=t*x,g+=t*V,U+=t*W,M+=t*Y,B+=t*K,F+=t*v,se+=t*Q,ie+=t*q,ae+=t*X,ue+=t*j,Ie+=t*$,Te+=t*Z,Ue+=t*J,t=e[9],C+=t*H,d+=t*y,b+=t*k,g+=t*x,U+=t*V,M+=t*W,B+=t*Y,F+=t*K,se+=t*v,ie+=t*Q,ae+=t*q,ue+=t*X,Ie+=t*j,Te+=t*$,Ue+=t*Z,Me+=t*J,t=e[10],d+=t*H,b+=t*y,g+=t*k,U+=t*x,M+=t*V,B+=t*W,F+=t*Y,se+=t*K,ie+=t*v,ae+=t*Q,ue+=t*q,Ie+=t*X,Te+=t*j,Ue+=t*$,Me+=t*Z,Ke+=t*J,t=e[11],b+=t*H,g+=t*y,U+=t*k,M+=t*x,B+=t*V,F+=t*W,se+=t*Y,ie+=t*K,ae+=t*v,ue+=t*Q,Ie+=t*q,Te+=t*X,Ue+=t*j,Me+=t*$,Ke+=t*Z,et+=t*J,t=e[12],g+=t*H,U+=t*y,M+=t*k,B+=t*x,F+=t*V,se+=t*W,ie+=t*Y,ae+=t*K,ue+=t*v,Ie+=t*Q,Te+=t*q,Ue+=t*X,Me+=t*j,Ke+=t*$,et+=t*Z,ht+=t*J,t=e[13],U+=t*H,M+=t*y,B+=t*k,F+=t*x,se+=t*V,ie+=t*W,ae+=t*Y,ue+=t*K,Ie+=t*v,Te+=t*Q,Ue+=t*q,Me+=t*X,Ke+=t*j,et+=t*$,ht+=t*Z,bt+=t*J,t=e[14],M+=t*H,B+=t*y,F+=t*k,se+=t*x,ie+=t*V,ae+=t*W,ue+=t*Y,Ie+=t*K,Te+=t*v,Ue+=t*Q,Me+=t*q,Ke+=t*X,et+=t*j,ht+=t*$,bt+=t*Z,Rs+=t*J,t=e[15],B+=t*H,F+=t*y,se+=t*k,ie+=t*x,ae+=t*V,ue+=t*W,Ie+=t*Y,Te+=t*K,Ue+=t*v,Me+=t*Q,Ke+=t*q,et+=t*X,ht+=t*j,bt+=t*$,Rs+=t*Z,zi+=t*J,o+=38*F,a+=38*se,A+=38*ie,u+=38*ae,h+=38*ue,c+=38*Ie,R+=38*Te,I+=38*Ue,S+=38*Me,C+=38*Ke,d+=38*et,b+=38*ht,g+=38*bt,U+=38*Rs,M+=38*zi,n=1,t=o+n+65535,n=Math.floor(t/65536),o=t-n*65536,t=a+n+65535,n=Math.floor(t/65536),a=t-n*65536,t=A+n+65535,n=Math.floor(t/65536),A=t-n*65536,t=u+n+65535,n=Math.floor(t/65536),u=t-n*65536,t=h+n+65535,n=Math.floor(t/65536),h=t-n*65536,t=c+n+65535,n=Math.floor(t/65536),c=t-n*65536,t=R+n+65535,n=Math.floor(t/65536),R=t-n*65536,t=I+n+65535,n=Math.floor(t/65536),I=t-n*65536,t=S+n+65535,n=Math.floor(t/65536),S=t-n*65536,t=C+n+65535,n=Math.floor(t/65536),C=t-n*65536,t=d+n+65535,n=Math.floor(t/65536),d=t-n*65536,t=b+n+65535,n=Math.floor(t/65536),b=t-n*65536,t=g+n+65535,n=Math.floor(t/65536),g=t-n*65536,t=U+n+65535,n=Math.floor(t/65536),U=t-n*65536,t=M+n+65535,n=Math.floor(t/65536),M=t-n*65536,t=B+n+65535,n=Math.floor(t/65536),B=t-n*65536,o+=n-1+37*(n-1),n=1,t=o+n+65535,n=Math.floor(t/65536),o=t-n*65536,t=a+n+65535,n=Math.floor(t/65536),a=t-n*65536,t=A+n+65535,n=Math.floor(t/65536),A=t-n*65536,t=u+n+65535,n=Math.floor(t/65536),u=t-n*65536,t=h+n+65535,n=Math.floor(t/65536),h=t-n*65536,t=c+n+65535,n=Math.floor(t/65536),c=t-n*65536,t=R+n+65535,n=Math.floor(t/65536),R=t-n*65536,t=I+n+65535,n=Math.floor(t/65536),I=t-n*65536,t=S+n+65535,n=Math.floor(t/65536),S=t-n*65536,t=C+n+65535,n=Math.floor(t/65536),C=t-n*65536,t=d+n+65535,n=Math.floor(t/65536),d=t-n*65536,t=b+n+65535,n=Math.floor(t/65536),b=t-n*65536,t=g+n+65535,n=Math.floor(t/65536),g=t-n*65536,t=U+n+65535,n=Math.floor(t/65536),U=t-n*65536,t=M+n+65535,n=Math.floor(t/65536),M=t-n*65536,t=B+n+65535,n=Math.floor(t/65536),B=t-n*65536,o+=n-1+37*(n-1),E[0]=o,E[1]=a,E[2]=A,E[3]=u,E[4]=h,E[5]=c,E[6]=R,E[7]=I,E[8]=S,E[9]=C,E[10]=d,E[11]=b,E[12]=g,E[13]=U,E[14]=M,E[15]=B}function To(E,e,s){let t,n;for(Ze(E[0],u_),Ze(E[1],li),Ze(E[2],li),Ze(E[3],u_),n=255;n>=0;--n)t=s[n/8|0]>>(n&7)&1,N_(E,e,t),I_(e,E),I_(E,E),N_(E,e,t)}function l_(E,e){let s=O(),t=O(),n=O();Oo(n,e[2]),oe(s,e[0],n),oe(t,e[1],n),S_(E,t),E[31]^=Uo(s)<<7}function Oo(E,e){let s=O(),t;for(t=0;t<16;t++)s[t]=e[t];for(t=253;t>=0;t--)po(s,s),t!==2&&t!==4&&oe(s,s,e);for(t=0;t<16;t++)E[t]=s[t]}function po(E,e){oe(E,e,e)}function Uo(E){let e=new Uint8Array(32);return S_(e,E),e[0]&1}function hi(E){let e,s,t=1;for(e=0;e<16;e++)s=E[e]+t+65535,t=Math.floor(s/65536),E[e]=s-t*65536;E[0]+=t-1+37*(t-1)}function S_(E,e){let s,t,n,o=O(),a=O();for(s=0;s<16;s++)a[s]=e[s];for(hi(a),hi(a),hi(a),t=0;t<2;t++){for(o[0]=a[0]-65517,s=1;s<15;s++)o[s]=a[s]-65535-(o[s-1]>>16&1),o[s-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),n=o[15]>>16&1,o[14]&=65535,f_(a,o,1-n)}for(s=0;s<16;s++)E[2*s]=a[s]&255,E[2*s+1]=a[s]>>8}function N_(E,e,s){for(let t=0;t<4;t++)f_(E[t],e[t],s)}function Pt(E,e,s){for(let t=0;t<16;t++)E[t]=e[t]+s[t]}function os(E,e,s){for(let t=0;t<16;t++)E[t]=e[t]-s[t]}function I_(E,e){let s=O(),t=O(),n=O(),o=O(),a=O(),A=O(),u=O(),h=O(),c=O();os(s,E[1],E[0]),os(c,e[1],e[0]),oe(s,s,c),Pt(t,E[0],E[1]),Pt(c,e[0],e[1]),oe(t,t,c),oe(n,E[3],e[3]),oe(n,n,Co),oe(o,E[2],e[2]),Pt(o,o,o),os(a,t,s),os(A,o,n),Pt(u,o,n),Pt(h,t,s),oe(E[0],a,A),oe(E[1],h,u),oe(E[2],u,A),oe(E[3],a,h)}function f_(E,e,s){let t=~(s-1),n;for(let o=0;o<16;o++)n=t&(E[o]^e[o]),E[o]^=n,e[o]^=n}var Es=ci;var Je=m(require("node:crypto"),1);var Lo=Buffer.from([48,46,2,1,0,48,5,6,3,43,101,112,4,34,4,32]),Ni=class extends ee{#e;constructor(e,s,t,n,o,a){super(n,a,o),this.multiAuthResolver=a,this.pluginData=t,this.sequenceNo=e,this.compressSequenceNo=s}start(e,s,t){t.extSalt?(this.parseExtSalt(Buffer.from(t.extSalt,"hex"),t),this.sendScramble(e,s,t)):(e.startPacket(this),e.writeEmptyPacket(!0),this.onPacketReceive=this.requestForSalt)}requestForSalt(e,s,t,n){this.parseExtSalt(e.readBufferRemaining(),n),this.sendScramble(s,t,n)}parseExtSalt(e,s){let t=0;if(e[t]==1&&(t+=1),e.length<2||e[t]!==80||e[t+1]>20)return this.throwError(w("Wrong parsec authentication format",N.ER_AUTHENTICATION_BAD_PACKET,s),s);this.iterations=e[t+1],this.salt=e.slice(t+2)}sendScramble(e,s,t){let n=Je.default.pbkdf2Sync(s.password||"",this.salt,1024<{let e=Buffer.from("302e020100300506032b657004220420","hex"),s=Buffer.concat([e,E]);return Je.default.createPrivateKey({key:s,format:"der",type:"pkcs8"})},C_=Ni;var Ii=class extends ee{constructor(e,s,t,n,o,a){super(n,a,o),this.pluginData=t,this.sequenceNo=e,this.compressSequenceNo=s,this.counter=0,this.multiAuthResolver=a}requireSecure(){return!0}start(e,s,t){this.exchange(this.pluginData,e,s,t),this.onPacketReceive=this.response}exchange(e,s,t,n){s.startPacket(this);let o;Array.isArray(t.password)?(o=t.password[this.counter],this.counter++):o=t.password,o&&s.writeString(o),s.writeInt8(0),s.flushPacket()}response(e,s,t,n){switch(e.peek()){case 0:case 255:return this.emit("send_end"),this.multiAuthResolver(e,s,t,n);default:let a=e.readBuffer();this.exchange(a,s,t,n),this.onPacketReceive=this.response}}},T_=Ii;var O_=m(require("node:fs"),1),Ri=m(require("node:crypto"),1);var as=m(require("node:crypto"),1),Si=class E extends ee{constructor(e,s,t,n,o,a){super(n,a,o),this.pluginData=t,this.sequenceNo=e,this.compressSequenceNo=s,this.counter=0,this.counter=0,this.initialState=!0,this.multiAuthResolver=a}start(e,s,t){this.exchange(this.pluginData,e,s,t),this.onPacketReceive=this.response}exchange(e,s,t,n){if(this.initialState){if(t.password)if(t.ssl){s.startPacket(this),t.password&&s.writeString(t.password),s.writeInt8(0),s.flushPacket();return}else if(t.rsaPublicKey)try{let o=t.rsaPublicKey;o.includes("-----BEGIN")||(o=O_.default.readFileSync(o,"utf8")),this.publicKey=E.retrievePublicKey(o)}catch(o){return this.throwError(o,n)}else{if(!t.allowPublicKeyRetrieval)return this.throwError(w("RSA public key is not available client side. Either set option `rsaPublicKey` to indicate public key path, or allow public key retrieval with option `allowPublicKeyRetrieval`",N.ER_CANNOT_RETRIEVE_RSA_KEY,n),n);this.initialState=!1,s.startPacket(this),s.writeInt8(1),s.flushPacket();return}else{s.startPacket(this),s.writeEmptyPacket(!0);return}E.sendSha256PwdPacket(this,this.pluginData,this.publicKey,t.password,s)}else this.publicKey=E.retrievePublicKey(e.toString("utf8",1)),E.sendSha256PwdPacket(this,this.pluginData,this.publicKey,t.password,s)}static retrievePublicKey(e){return e.replace("(-+BEGIN PUBLIC KEY-+\\r?\\n|\\n?-+END PUBLIC KEY-+\\r?\\n?)","")}static sendSha256PwdPacket(e,s,t,n,o){let a=s.slice(0,s.length-1);o.startPacket(e);let A=E.encrypt(a,n,t);o.writeBuffer(A,0,A.length),o.flushPacket()}static encryptSha256Password(e,s){if(!e)return Buffer.alloc(0);let t=as.default.createHash("sha256"),n=t.update(e,"utf8").digest();t=as.default.createHash("sha256");let o=t.update(n).digest();t=as.default.createHash("sha256"),t.update(o),t.update(s);let a=t.digest(),A=Buffer.allocUnsafe(a.length);for(let u=0;u0?(s.writeBuffer(a,0,a.length),s.flushPacket()):s.writeEmptyPacket(!0),this.state=ze.FAST_AUTH_RESULT;return;case ze.FAST_AUTH_RESULT:switch(e[1]){case 3:return;case 4:if(this.isSecureConnection(t)){if(n.requireValidCert&&n.selfSignedCertificate)return this.throwError(w("cannot send a `caching_sha2_password` and SSL without providing server certificates, cannot send password in clear on an untrusted SSL connection",N.ER_SELF_SIGNED_SHA256,n),n);s.startPacket(this),s.writeString(t.password),s.writeInt8(0),s.flushPacket();return}if(t.cachingRsaPublicKey){try{let u=t.cachingRsaPublicKey;u.includes("-----BEGIN")||(u=d_.default.readFileSync(u,"utf8")),this.publicKey=xe.retrievePublicKey(u)}catch(u){return this.throwError(u,n)}xe.sendSha256PwdPacket(this,this.pluginData,this.publicKey,t.password,s)}else{if(!t.allowPublicKeyRetrieval)return this.throwError(w("RSA public key is not available client side. Either set option `cachingRsaPublicKey` to indicate public key path, or allow public key retrieval with option `allowPublicKeyRetrieval`",N.ER_CANNOT_RETRIEVE_RSA_KEY,n),n);this.state=ze.REQUEST_SERVER_KEY,s.startPacket(this),s.writeInt8(2),s.flushPacket()}}return;case ze.REQUEST_SERVER_KEY:this.publicKey=xe.retrievePublicKey(e.toString(void 0,1)),this.state=ze.SEND_AUTH,xe.sendSha256PwdPacket(this,this.pluginData,this.publicKey,t.password,s);return}}response(e,s,t,n){switch(e.peek()){case 0:case 255:return this.emit("send_end"),this.multiAuthResolver(e,s,t,n);default:let a=e.readBufferRemaining();this.exchange(a,s,t,n),this.onPacketReceive=this.response}}},p_=fi;var mo={mysql_native_password:At,mysql_clear_password:A_,client_ed25519:Es,parsec:C_,dialog:T_,sha256_password:xe,caching_sha2_password:p_},Ti=class E extends re{constructor(e,s,t,n,o,a){super(e,t,n),this.cmdParam=e,this._createSecureContext=o,this.getSocket=a,this.plugin=new a_(this,s,a,this.handshakeResult,n)}onPacketReceive(e,s,t,n){this.plugin.sequenceNo=this.sequenceNo,this.plugin.compressSequenceNo=this.compressSequenceNo,this.plugin.onPacketReceive(e,s,t,n)}handshakeResult(e,s,t,n){let o=e.peek();switch(o){case 254:this.dispatchAuthSwitchRequest(e,s,t,n);return;case 0:if(this.plugin.onPacketReceive=null,e.skip(1),e.skipLengthCodedNumber(),e.skipLengthCodedNumber(),n.status=e.readUInt16(),n.requireValidCert)if(n.selfSignedCertificate){if(e.skip(2),e.remaining()){let u=e.readBufferLengthEncoded();if(u.length>0){if(!this.plugin.isMitmProof()||!this.cmdParam.opts.password)return this.throwNewError("Self signed certificates. Either set `ssl: { rejectUnauthorized: false }` (trust mode) or provide server certificate to client",!0,n,"08000",N.ER_SELF_SIGNED_NO_PWD);if(this.validateFingerPrint(u,n))return this.successEnd()}}return this.throwNewError("self-signed certificate",!0,n,"08000",N.ER_SELF_SIGNED)}else{let h=(t.ssl===!0||typeof t.ssl.checkServerIdentity!="function"?U_.default.checkServerIdentity:t.ssl.checkServerIdentity)(typeof t.ssl=="object"&&t.ssl.servername?t.ssl.servername:t.host,n.tlsCert);if(h)return this.throwNewError("certificate identify Error: "+h.message,!0,n,"08000",N.ER_TLS_IDENTITY_ERROR)}let a=!1;if(n.status&16384)for(e.skip(2),e.skipLengthCodedNumber();e.remaining();){let u=e.readUnsignedLength();if(u>0){let h=e.subPacketLengthEncoded(u);for(;h.remaining();)switch(h.readUInt8()){case 0:let R;do{R=h.subPacketLengthEncoded(h.readUnsignedLength());let S=R.readStringLengthEncoded(),C=R.readStringLengthEncoded();switch(S){case"character_set_client":if(n.collation=P.fromCharset(C),n.collation===void 0){this.throwError(new Error("unknown charset : '"+C+"'"),n);return}t.emit("collation",n.collation);break;case"redirect_url":C!==""&&(a=!0,n.redirect(C,this.successEnd.bind(this)));break;case"maxscale":n.maxscaleVersion=C;break;case"connection_id":n.threadId=parseInt(C);break;default:}}while(R.remaining()>0);break;case 1:let I=h.subPacketLengthEncoded(h.readUnsignedLength());n.database=I.readStringLengthEncoded();break}}}a||this.successEnd();return;case 255:this.plugin.onPacketReceive=null;let A=e.readError(n,this.displaySql(),void 0);return A.fatal=!0,n.requireValidCert&&n.selfSignedCertificate?this.plugin.throwNewError("Self signed certificates. Either set `ssl: { rejectUnauthorized: false }` (trust mode) or provide server certificate to client",!0,n,"08000",N.ER_SELF_SIGNED_NO_PWD):this.plugin.throwError(A,n);default:this.throwNewError(`Unexpected type of packet during handshake phase : ${o}`,!0,n,"42000",N.ER_AUTHENTICATION_BAD_PACKET)}}validateFingerPrint(e,s){if(e.length===0||!s.tlsFingerprint)return!1;if(e[0]!==1){let c=w("Unexpected hash format for fingerprint hash encoding",N.ER_UNEXPECTED_PACKET,this.info);return this.opts.logger.error&&this.opts.logger.error(c),!1}let t=this.plugin.hash(this.cmdParam.opts),o=Ci.default.createHash("sha256").update(t).update(s.seed).update(Buffer.from(s.tlsFingerprint,"hex")).digest(),a=vr(o),A=e.toString("ascii",1,e.length).toLowerCase(),u=Buffer.from(a,"ascii"),h=Buffer.from(A,"ascii");return u.length===h.length&&Ci.default.timingSafeEqual(u,h)}dispatchAuthSwitchRequest(e,s,t,n){let o,a;if(n.clientCapabilities&Re?(e.skip(1),e.remaining()?(o=e.readStringNullEnded(),a=e.readBufferRemaining()):(o="mysql_old_password",a=n.seed.subarray(0,8))):(o=e.readStringNullEnded("ascii"),a=e.readBufferRemaining()),t.restrictedAuth&&!t.restrictedAuth.includes(o)){this.throwNewError(`Unsupported authentication plugin ${o}. Authorized plugin: ${t.restrictedAuth.toString()}`,!0,n,"42000",N.ER_NOT_SUPPORTED_AUTH_PLUGIN);return}try{if(this.plugin.emit("end"),this.plugin.onPacketReceive=null,this.plugin=E.pluginHandler(o,this.plugin.sequenceNo,this.plugin.compressSequenceNo,a,n,t,s,this.cmdParam,this.reject,this.handshakeResult.bind(this)),this.plugin.requireSecure()&&!this.plugin.isSecureConnection(t))return this.throwNewError(`${o} authentication requires TLS or a local socket`,!0,n,"08S01",N.ER_CLEAR_PASSWORD_WITHOUT_SSL);if(n.requireValidCert&&n.selfSignedCertificate&&this.cmdParam.opts.password&&!this.plugin.isMitmProof())return this.throwNewError(`Unsupported authentication plugin ${o} with Self signed certificates. Either set 'ssl: { rejectUnauthorized: false }' (trust mode) or provide server certificate to client`,!0,n,"08000",N.ER_SELF_SIGNED_BAD_PLUGIN);this.plugin.start(s,t,n)}catch(A){this.reject(A)}}static pluginHandler(e,s,t,n,o,a,A,u,h,c){let R=mo[e];if(!R)throw w(`Client does not support authentication protocol '${e}' requested by server.`,N.ER_AUTHENTICATION_PLUGIN_NOT_SUPPORTED,o,"08004");return new R(s,t,n,u,h,c)}},As=Ti;var Do=new Uint8Array([1,0,0,0,1]),Oi=class extends re{constructor(e,s,t){super(e,s,t)}start(e,s,t){s.logger.query&&s.logger.query("QUIT"),this.onPacketReceive=this.skipResults,e.fastFlush(this,Do),this.emit("send_end"),this.successEnd()}skipResults(e,s,t,n){}},di=Oi;var wo=new Uint8Array([1,0,0,0,14]),pi=class extends re{constructor(e,s,t){super(e,s,t)}start(e,s,t){s.logger.query&&s.logger.query("PING"),this.onPacketReceive=this.readPingResponsePacket,e.fastFlush(this,wo),this.emit("send_end")}readPingResponsePacket(e,s,t,n){e.skip(1),e.skipLengthCodedNumber(),e.skipLengthCodedNumber(),n.status=e.readUInt16(),n.redirectRequest&&(n.status&1)===0?n.redirect(n.redirectRequest,this.successEnd.bind(this,null)):this.successEnd(null)}},Ui=pi;var go=new Uint8Array([1,0,0,0,31]),Li=class extends re{constructor(e,s,t){super(e,s,t)}start(e,s,t){s.logger.query&&s.logger.query("RESET"),this.onPacketReceive=this.readResetResponsePacket,e.fastFlush(this,go),this.emit("send_end")}readResetResponsePacket(e,s,t,n){e.skip(1),e.skipLengthCodedNumber(),e.skipLengthCodedNumber(),n.status=e.readUInt16(),n.redirectRequest&&(n.status&1)===0?n.redirect(n.redirectRequest,this.successEnd.bind(this)):this.successEnd()}},L_=Li;var Pi=class{static writeParam(e,s,t,n){switch(typeof s){case"boolean":e.writeInt8(s?1:0);break;case"bigint":s>=2n**63n?e.writeLengthEncodedString(s.toString()):e.writeBigInt(s);break;case"number":if(Number.isInteger(s)&&s>=-2147483648&&s<2147483647){e.writeInt32(s);break}e.writeDouble(s);break;case"string":e.writeLengthEncodedString(s);break;case"object":Object.prototype.toString.call(s)==="[object Date]"?e.writeBinaryDate(s):Buffer.isBuffer(s)?e.writeLengthEncodedBuffer(s):typeof s.toSqlString=="function"?e.writeLengthEncodedString(String(s.toSqlString())):e.writeLengthEncodedString(JSON.stringify(s));break;default:e.writeLengthEncodedBuffer(s)}}static getBufferFromGeometryValue(e,s){let t,n,o;if(s){switch(s){case"MultiPoint":return e&&Array.isArray(e)&&e.length>=2&&!isNaN(e[0])&&!isNaN(e[1])?(t=Buffer.allocUnsafe(21),t.writeInt8(1,0),t.writeInt32LE(1,1),t.writeDoubleLE(e[0],5),t.writeDoubleLE(e[1],13),t):null;case"MultiLineString":if(e&&Array.isArray(e)){let a=e.length;t=Buffer.allocUnsafe(9+16*a),t.writeInt8(1,0),t.writeInt32LE(2,1),t.writeInt32LE(a,5);for(let A=0;A=2&&!isNaN(e[A][0])&&!isNaN(e[A][1]))t.writeDoubleLE(e[A][0],9+16*A),t.writeDoubleLE(e[A][1],17+16*A);else return null;return t}return null;case"MultiPolygon":if(e&&Array.isArray(e)){let a=e.length,A=0;for(let u=0;u=2&&!isNaN(h[c][0])&&!isNaN(h[c][1]))t.writeDoubleLE(h[c][0],n),t.writeDoubleLE(h[c][1],n+8),n+=16;else return null}}return t}return null}return null}else{switch(e.type){case"Point":return t=Buffer.allocUnsafe(21),t.writeInt8(1,0),t.writeInt32LE(1,1),e.coordinates&&Array.isArray(e.coordinates)&&e.coordinates.length>=2&&!isNaN(e.coordinates[0])&&!isNaN(e.coordinates[1])?(t.writeDoubleLE(e.coordinates[0],5),t.writeDoubleLE(e.coordinates[1],13),t):null;case"LineString":if(e.coordinates&&Array.isArray(e.coordinates)){let a=e.coordinates.length;t=Buffer.allocUnsafe(9+16*a),t.writeInt8(1,0),t.writeInt32LE(2,1),t.writeInt32LE(a,5);for(let A=0;A=2&&!isNaN(e.coordinates[A][0])&&!isNaN(e.coordinates[A][1]))t.writeDoubleLE(e.coordinates[A][0],9+16*A),t.writeDoubleLE(e.coordinates[A][1],17+16*A);else return null;return t}else return null;case"Polygon":if(e.coordinates&&Array.isArray(e.coordinates)){let a=e.coordinates.length,A=0;for(let u=0;u=2&&!isNaN(h[c][0])&&!isNaN(h[c][1]))t.writeDoubleLE(h[c][0],n),t.writeDoubleLE(h[c][1],n+8),n+=16;else return null}}return t}else return null;case"MultiPoint":o="MultiPoint",t=Buffer.allocUnsafe(9),t.writeInt8(1,0),t.writeInt32LE(4,1);break;case"MultiLineString":o="MultiLineString",t=Buffer.allocUnsafe(9),t.writeInt8(1,0),t.writeInt32LE(5,1);break;case"MultiPolygon":o="MultiPolygon",t=Buffer.allocUnsafe(9),t.writeInt8(1,0),t.writeInt32LE(6,1);break;case"GeometryCollection":if(t=Buffer.allocUnsafe(9),t.writeInt8(1,0),t.writeInt32LE(7,1),e.geometries&&Array.isArray(e.geometries)){let a=e.geometries.length,A=[t];for(let u=0;u=Mo?this.parametersType[a]=Ho:this.parametersType[a]=yo;break;case"number":if(Number.isInteger(o)&&o>=-2147483648&&o<2147483647){this.parametersType[a]=ko;break}this.parametersType[a]=xo;break;case"string":this.parametersType[a]=Vo;break;case"object":o instanceof Date?this.parametersType[a]=Yo:Buffer.isBuffer(o)?o.length<16384||!this.prepare?this.parametersType[a]=Ko:(this.parametersType[a]=vo,n=!0):typeof o.toSqlString=="function"?this.parametersType[a]=Qo:typeof o.pipe=="function"&&typeof o.read=="function"?(n=!0,this.parametersType[a]=qo):String===o.constructor?this.parametersType[a]=Wo:this.parametersType[a]=Xo;break}}if(this.longDataStep=!1,n){for(let a=0;athis.values.length)return this.sendCancelled(`Parameter at position ${this.values.length} is not set\\nsql: ${this.opts.logParam?this.displaySql():this.sql}`,N.ER_MISSING_PARAMETER,e),!1;if(this.opts.namedPlaceholders&&this.placeHolderIndex){for(let s=0;s{e.writeBuffer(n,0,n.length)}),t.on("end",()=>{e.flush(),this.currentParam++,this.paramWritten()})}sendComStmtExecute(e,s){let t=~~((this.parameterCount+7)/8),n=Buffer.alloc(t);for(let o=0;o>3]|=1<<(o&7));e.startPacket(this),e.writeInt8(23),e.writeInt32(this.prepare?this.prepare.id:-1),e.writeInt8(0),e.writeInt32(1),e.writeBuffer(n,0,t),e.writeInt8(1);for(let o=0;o{if(this.longDataStep){for(;this.currentParamE.writeInt8(e?1:0)),Ho=new te(246,(E,e)=>E.writeLengthEncodedString(e.toString())),yo=new te(8,(E,e)=>E.writeBigInt(e)),ko=new te(3,(E,e)=>E.writeInt32(e)),xo=new te(5,(E,e)=>E.writeDouble(e)),Vo=new te(253,(E,e)=>E.writeLengthEncodedString(e)),Wo=new te(253,(E,e)=>E.writeLengthEncodedString(e.toString())),Yo=new te(12,(E,e)=>E.writeBinaryDate(e)),Ko=new te(252,(E,e)=>E.writeLengthEncodedBuffer(e)),vo=new te(252,null),Qo=new te(253,(E,e)=>E.writeLengthEncodedString(String(e.toSqlString()))),qo=new te(252,null),Xo=new te(253,(E,e)=>E.writeLengthEncodedString(JSON.stringify(e))),mt=wi;var D_=require("node:stream"),gi=class extends mt{constructor(e,s,t,n){super(()=>{},()=>{},s,e,t),this.socket=n,this.inStream=new D_.Readable({objectMode:!0,read:()=>{this.socket.resume()}}),this.on("fields",function(o){this.inStream.emit("fields",o)}),this.on("error",function(o){this.inStream.emit("error",o)}),this.on("close",function(o){this.inStream.emit("error",o)}),this.on("end",function(o){o&&this.inStream.emit("error",o),this.socket.resume(),this.inStream.push(null)}),this.inStream.close=function(){this.handleNewRows=()=>{},this.socket.resume()}.bind(this)}handleNewRows(e){this.inStream.push(e)||this.socket.pause()}},w_=gi;var bi=class{#e;constructor(e,s,t,n,o,a,A){this.id=e,this.parameterCount=s,this.columns=t,this.database=n,this.query=o,this.closed=!1,this._placeHolderIndex=a,this.#e=A}get conn(){return this.#e}execute(e,s,t,n){let o=s,a=t;if(typeof o=="function"&&(a=o,o=void 0),this.isClose()){let c=this.query;if(this.conn.opts.logParam)if(this.query.length>this.conn.opts.debugLen)c=this.query.substring(0,this.conn.opts.debugLen)+"...";else{let I=this.query+" - parameters:";c=Se.logParameters(this.conn.opts,I,e)}let R=f("Execute fails, prepare command as already been closed",N.ER_PREPARE_CLOSED,null,"22000",c);if(a){a(R);return}else return Promise.reject(R)}let A={sql:this.query,values:e,opts:o,callback:a};n&&(A.stack=n);let u=this.conn,h=new Promise((c,R)=>u.executePromise.call(u,A,this,c,R));if(a)h.then(c=>{a&&a(null,c,null)}).catch(a||function(c){});else return h}executeStream(e,s,t,n){let o=s,a=t;if(typeof o=="function"&&(a=o,o=void 0),this.isClose()){let h=f("Execute fails, prepare command as already been closed",N.ER_PREPARE_CLOSED,null,"22000",this.query);if(a){a(h);return}else throw h}let A={sql:this.query,values:e,opts:o,callback:a};n&&(A.stack=n);let u=new w_(A,this.conn.opts,this,this.conn.socket);return this.conn.opts.logger.error&&u.on("error",this.conn.opts.logger.error),this.conn.addCommand(u,!0),u.inStream}isClose(){return this.closed}close(){this.closed||(this.closed=!0,this.#e.emit("close_prepare",this))}toString(){return"Prepare{closed:"+this.closed+"}"}},g_=bi;var Mi=class extends Se{constructor(e,s,t,n,o){super(e,s,t,n),this.encoder=new Ve(this.opts),this.binary=!0,this.conn=o,this.executeCommand=n.executeCommand}start(e,s,t){if(this.conn.prepareCache){let n=this.conn.prepareCache.get(this.sql);if(n)return this.emit("send_end"),this.successEnd(n)}if(s.logger.query&&s.logger.query(`PREPARE: ${this.sql}`),this.onPacketReceive=this.readPrepareResultPacket,this.opts.namedPlaceholders){let n=yt(this.sql);this.sql=n.sql,this.placeHolderIndex=n.placeHolderIndex}e.startPacket(this),e.writeInt8(22),e.writeString(this.sql),e.flush(),this.emit("send_end")}successPrepare(e,s){let t=new g_(this.statementId,this.parameterCount,this._columns,e.database,this.sql,this.placeHolderIndex,this.conn);if(this.conn.prepareCache){let n=new m_(t);this.conn.prepareCache.set(this.sql,n);let o=n.incrementUse();return this.executeCommand&&(this.executeCommand.prepare=o),this.successEnd(o)}this.executeCommand&&(this.executeCommand.prepare=t),this.successEnd(t)}readPrepareResultPacket(e,s,t,n){switch(e.peek()){case 0:return e.skip(1),this.statementId=e.readInt32(),this.columnNo=e.readUInt16(),this.parameterCount=e.readUInt16(),this._parameterNo=this.parameterCount,this._columns=[],this._parameterNo>0?this.onPacketReceive=this.skipPrepareParameterPacket:this.columnNo>0?this.onPacketReceive=this.readPrepareColumnsPacket:this.successPrepare(n,t);case 255:let o=e.readError(n,this.displaySql(),this.stack);return n.status|=1,this.onPacketReceive=this.readResponsePacket,this.throwError(o,n);default:return n.status|=1,this.onPacketReceive=this.readResponsePacket,this.throwError(N.ER_UNEXPECTED_PACKET,n)}}readPrepareColumnsPacket(e,s,t,n){if(this.columnNo--,this._columns.push(new Ht(e,n,t.rowsAsArray)),this.columnNo===0){if(n.eofDeprecated)return this.successPrepare(n,t);this.onPacketReceive=this.skipEofPacket}}skipEofPacket(e,s,t,n){if(this.columnNo>0)return this.onPacketReceive=this.readPrepareColumnsPacket;this.successPrepare(n,t)}skipPrepareParameterPacket(e,s,t,n){if(this._parameterNo--,this._parameterNo===0){if(n.eofDeprecated)return this.columnNo>0?this.onPacketReceive=this.readPrepareColumnsPacket:this.successPrepare(n,t);this.onPacketReceive=this.skipEofPacket}}displaySql(){return this.opts&&this.sql.length>this.opts.debugLen?this.sql.substring(0,this.opts.debugLen)+"...":this.sql}},us=Mi;var Bi=class extends re{constructor(e,s,t,n){super(e,s,t),this.prepare=n}start(e,s,t){s.logger.query&&s.logger.query(`CLOSE PREPARE: (${this.prepare.id}) ${this.prepare.query}`);let n=new Uint8Array([5,0,0,0,25,this.prepare.id,this.prepare.id>>8,this.prepare.id>>16,this.prepare.id>>24]);e.fastFlush(this,n),this.onPacketReceive=null,this.emit("send_end"),this.emit("end")}},b_=Bi;var Gi=["Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon","GeometryCollection"],Fi=class extends Se{constructor(e,s,t,n,o){super(e,s,t,o),this.cmdOpts=o.opts,this.binary=!0,this.prepare=n,this.canSkipMeta=!0,this.bulkPacketNo=0,this.sending=!1,this.firstError=null}start(e,s,t){if(this.info=t,this.values=this.initialValues,this.cmdOpts&&this.cmdOpts.timeout)return this.handleTimeoutError(t);this.onPacketReceive=this.readResponsePacket,this.opts.namedPlaceholders&&this.prepare._placeHolderIndex&&this.processNamedPlaceholders(),this.validateParameters(t)&&this.sendComStmtBulkExecute(e,s,t)}handleTimeoutError(e){return this.bulkPacketNo=1,this.sending=!1,this.sendCancelled("Cannot use timeout for Batch statement",N.ER_TIMEOUT_NOT_SUPPORTED)}processNamedPlaceholders(){if(this.values=[],!this.initialValues)return;let e=this.prepare._placeHolderIndex,s=this.prepare.parameterCount;for(let t=0;t=2n**63n?246:8;break;case"number":Number.isInteger(o)&&o>=-2147483648&&o<2147483647?t[n]=3:t[n]=5;break;case"string":t[n]=253;break;case"object":t[n]=this.getObjectFieldType(o);break;default:t[n]=252}}return t}getObjectFieldType(e){return Object.prototype.toString.call(e)==="[object Date]"?12:Buffer.isBuffer(e)?252:typeof e.toSqlString=="function"?253:e.type!=null&&Gi.includes(e.type)?252:253}checkSameHeader(e,s,t){for(let n=0;n=2n**63n){if(e[n]!==253)return!1}else if(e[n]!==8)return!1;break;case"number":if(Number.isInteger(o)&&o>=-2147483648&&o<2147483647){if(e[n]!==3)return!1}else if(e[n]!==5)return!1;break;case"string":if(e[n]!==253)return!1;break;case"object":if(!this.checkObjectHeaderType(o,e[n]))return!1;break;default:if(e[n]!==252)return!1}}return!0}checkObjectHeaderType(e,s){return Object.prototype.toString.call(e)==="[object Date]"?s===7:Buffer.isBuffer(e)?s===252:typeof e.toSqlString=="function"?s===253:e.type!=null&&Gi.includes(e.type)?s===252:s===253}sendComStmtBulkExecute(e,s,t){s.logger.query&&s.logger.query(`BULK: (${this.prepare.id}) sql: ${s.logParam?this.displaySql():this.sql}`);let n=this.prepare.parameterCount;this.rowIdx=0,this.vals=this.values[this.rowIdx++];let o=this.parameterHeaderFromValue(this.vals,n),a=null;this.bulkPacketNo=0,this.sending=!0;e:for(;;){this.bulkPacketNo++,e.startPacket(this),e.writeInt8(250),e.writeInt32(this.prepare.id),this.useUnitResult=(t.clientCapabilities&st)>0,e.writeInt16(this.useUnitResult?192:128);for(let A=0;A=this.values.length)break;this.vals=this.values[this.rowIdx++]}t:for(;;){for(let A=0;A=this.values.length)break e;if(this.vals=this.values[this.rowIdx++],!this.checkSameHeader(o,this.vals,n)){e.flush(),o=this.parameterHeaderFromValue(this.vals,n);break t}}}e.flush(),this.sending=!1,this.emit("send_end")}writeGeoJSONParam(e,s,t){let n=Ve.getBufferFromGeometryValue(s);if(n==null)e.writeInt8(1);else{e.writeInt8(0);let o=Buffer.concat([Buffer.from([0,0,0,0]),n]);Ve.writeParam(e,o,this.opts,t)}}displaySql(){if(this.sql.length>this.opts.debugLen)return this.sql.substring(0,this.opts.debugLen)+"...";let e=this.sql+" - parameters:[";for(let s=0;sthis.opts.debugLen)return e.substring(0,this.opts.debugLen)+"..."}return e+="]",e}success(e){if(this.bulkPacketNo--,!this.sending&&this.bulkPacketNo===0){this.packet=null,this.firstError?(this.resolve=null,this.onPacketReceive=null,this._columns=null,this._rows=null,process.nextTick(this.reject,this.firstError),this.reject=null,this.emit("end",this.firstError)):this.processResults();return}this.firstError||(this._responseIndex++,this.onPacketReceive=this.readResponsePacket)}processResults(){this._rows[0]&&this._rows[0][0]&&this._rows[0][0].Affected_rows!==void 0?this.processUnitResults():this._rows[0].affectedRows!==void 0&&!(this.opts.fullResult===void 0||this.opts.fullResult===!0)?this.processAggregatedResults():this.processRowResults(),this._columns=null,this._rows=null}processUnitResults(){if(this.opts.fullResult===void 0||this.opts.fullResult===!0){let e=[];this._rows.forEach(s=>{s.forEach(t=>{e.push(new ce(Number(t.Affected_rows),BigInt(t.Id),0))})}),this.successEnd(this.opts.metaAsArray?[e,[]]:e)}else{let e=0;this._rows.forEach(t=>{t.forEach(n=>{e+=Number(n.Affected_rows)})});let s=new ce(e,BigInt(this._rows[0][0].Id),0);this.successEnd(this.opts.metaAsArray?[s,[]]:s)}}processAggregatedResults(){let e=0;this._rows.forEach(t=>{e+=t.affectedRows});let s=new ce(e,this._rows[0].insertId,this._rows[this._rows.length-1].warningStatus);this.successEnd(this.opts.metaAsArray?[s,[]]:s)}processRowResults(){if(this._rows.length===1){this.successEnd(this.opts.metaAsArray?[this._rows[0],this._columns]:this._rows[0]);return}if(this.opts.metaAsArray)if(this.useUnitResult){let e=[];this._rows.forEach((s,t)=>{t%2===0&&e.push(...s)}),this.successEnd([e,this.prepare.columns])}else{let e=[];this._rows.forEach(s=>{e.push(...s)}),this.successEnd([e,this._columns])}else if(this.useUnitResult){let e=[];this._rows.forEach((s,t)=>{t%2===0&&e.push(...s)}),Object.defineProperty(e,"meta",{value:this._columns,writable:!0,enumerable:this.opts.metaEnumerable}),this.successEnd(e)}else if(this._rows.length===1)this.successEnd(this._rows[0]);else{let e=[];Array.isArray(this._rows[0])?this._rows.forEach(s=>{e.push(...s)}):e.push(...this._rows),Object.defineProperty(e,"meta",{value:this._columns,writable:!0,enumerable:this.opts.metaEnumerable}),this.successEnd(e)}}okPacketSuccess(e,s){if(this._rows.push(e),s.status&8)return this._responseIndex++,this.onPacketReceive=this.readResponsePacket;this.opts.metaAsArray?(this._meta||(this._meta=new Array(this._responseIndex)),this._meta[this._responseIndex]=null,this.success([this._rows,this._meta])):this.success(this._rows)}throwError(e,s){this.bulkPacketNo--,this.firstError||(e.fatal&&(this.bulkPacketNo=0),this.cmdParam.stack&&(e=f(e.message,e.errno,s,e.sqlState,this.opts.logParam?this.displaySql():this.sql,e.fatal,this.cmdParam.stack,!1)),this.firstError=e),!this.sending&&this.bulkPacketNo===0?(this.resolve=null,this.emit("send_end"),process.nextTick(this.reject,this.firstError),this.reject=null,this.onPacketReceive=null,this.emit("end",this.firstError)):this.onPacketReceive=this.readResponsePacket}validateParameters(e){let s=this.prepare.parameterCount;for(let t=0;t{},o),this.configAssign(s,e.opts)}start(e,s,t){s.logger.query&&s.logger.query(`CHANGE USER to '${this.opts.user||""}'`);let n,o=Array.isArray(this.opts.password)?this.opts.password[0]:this.opts.password;switch(t.defaultPluginName){case"mysql_native_password":case"":n=At.encryptSha1Password(o,t.seed);break;case"client_ed25519":n=Es.encryptPassword(o,t.seed);break;default:n=Buffer.alloc(0);break}if(e.startPacket(this),e.writeInt8(17),e.writeString(this.opts.user||""),e.writeInt8(0),t.serverCapabilities&Ge?(e.writeInt8(n.length),e.writeBuffer(n,0,n.length)):(e.writeBuffer(n,0,n.length),e.writeInt8(0)),t.clientCapabilities&qe&&(e.writeString(this.opts.database),e.writeInt8(0),t.database=this.opts.database),this.opts.collation?(!this.opts.charset||t.collation.charset!==this.opts.collation.charset)&&(t.collation=this.opts.collation):(t.collation.charset!=="utf8"||t.collation.maxLength===3)&&(t.collation=P.fromIndex(224)),e.writeInt16(t.collation.index),t.clientCapabilities&Re&&(e.writeString(t.defaultPluginName),e.writeInt8(0)),t.clientCapabilities&tt){e.writeInt8(252);let a=e.pos;e.writeInt16(0);let A=t.collation.charset;if(We(e,"_client_name",A),We(e,"MariaDB connector/Node",A),We(e,"_client_version",A),We(e,Be.version,A),We(e,"_node_version",A),We(e,process.versions.node,A),s.connectAttributes!==!0){let u=Object.keys(this.opts.connectAttributes);for(let h=0;ht.unCache()})}get(e){let s=this.#t.database+"|"+e,t=this.#e.get(s);return t?t.incrementUse():null}set(e,s){let t=this.#t.database+"|"+e;this.#e.set(t,s)}toString(){let e=[...this.#e.keys()];return`info{cache:${e.length?e.map(t=>`[${t}]`).join(","):""}}`}reset(){this.#e.clear()}},H_=yi;var k_=require("node:fs");var hs=function(E,e){if(E==="UTC"||E==="Etc/UTC"||E==="Z"||E==="Etc/GMT")return"+00:00";if(E.startsWith("Etc/GMT")||E.startsWith("GMT")){let s,t;E.startsWith("Etc/GMT")?(s=E.substring(7),t=!s.startsWith("-")):(s=E.substring(3),t=s.startsWith("-"));let n=parseInt(s.substring(1));if(isNaN(n))throw w(`Automatic timezone setting fails. wrong Server timezone '${E}' conversion to +/-HH:00 conversion.`,N.ER_WRONG_AUTO_TIMEZONE,e.info);return(t?"-":"+")+(n>=10?n:"0"+n)+":00"}return E},jo=/(mariadb|mysql):\/\/(([^/@:]+)?(:([^/]+))?@)?(([^/:]+)(:([0-9]+))?)(\/([^?]+)(\?(.*))?)?$/,xi=class E extends ki.default{opts;sendQueue=new Dt.default;receiveQueue=new Dt.default;waitingAuthenticationQueue=new Dt.default;status=1;socket=null;timeout=null;addCommand;streamOut;streamIn;info;prepareCache;constructor(e){super(),this.opts=Object.assign(new ki.default,e),this.info=new Lt(this.opts,this.redirect.bind(this)),this.prepareCache=this.opts.prepareCacheLength>0?new H_(this.info,this.opts.prepareCacheLength):null,this.addCommand=this.addCommandQueue,this.streamOut=new t_(this.opts,this.info),this.streamIn=new jr(this.unexpectedPacket.bind(this),this.receiveQueue,this.streamOut,this.opts,this.info),this._boundSendNextCmd=this._sendNextCmdImmediate.bind(this),this.on("close_prepare",this._closePrepare.bind(this)),this.escape=Ot.bind(this,this.opts,this.info),this.escapeId=Zt.bind(this,this.opts,this.info)}connect(){let e=this;this.status=2;let s={opts:this.opts};return new Promise(function(t,n){e.connectRejectFct=n,e.connectResolveFct=t;let o=new As(s,e.opts.host,e.authSucceedHandler.bind(e),e.authFailHandler.bind(e),e.createSecureContext.bind(e),e.getSocket.bind(e));Error.captureStackTrace(o),o.once("end",()=>{e.receiveQueue.shift(),!e.opts.collation&&e.info.collation&&e.opts.emit("collation",e.info.collation),process.nextTick(e.nextSendCmd.bind(e))}),e.receiveQueue.push(o),e.streamInitSocket.call(e)})}executePromise(e,s,t,n){let o=new mt(t,this._logAndReject.bind(this,n),this.opts,e,s);this.addCommand(o,!0)}batch(e,s,t){if(!e.sql)return this.handleMissingSqlError(t);if(!e.values)return this.handleMissingValuesError(e,t);Array.isArray(e.values)&&e.values.length===0&&s(),this.prepare(e,n=>this.executeBatch(e,n,s,t),n=>this._logAndReject(t,n))}handleMissingSqlError(e){let s=f("sql parameter is mandatory",N.ER_UNDEFINED_SQL,this.info,"HY000",null,!1);Error.captureStackTrace(s,this.handleMissingSqlError),this._logAndReject(e,s)}handleMissingValuesError(e,s){let t=e.sql,n=t.length>this.opts.debugLen?t.substring(0,this.opts.debugLen)+"...":t,o=f("Batch must have values set",N.ER_BATCH_WITH_NO_VALUES,this.info,"HY000",n,!1,e.stack);this._logAndReject(s,o)}executeBatch(e,s,t,n){let o=e.opts&&e.opts.namedPlaceholders||this.opts.namedPlaceholders,a=this.formatBatchValues(e.values,o,s.parameterCount);e.values=a,this._canUseBulk(a,e.opts)?this.executeBulkPromise(e,s,this.opts,t,n):this.executeIndividualBatches(e,s,t,n)}executeBulkPromise(e,s,t,n,o){let a=new M_(A=>(s.close(),n(A)),A=>{s.close(),t.logger.error&&t.logger.error(A),o(A)},t,s,e);this.addCommand(a,!0)}formatBatchValues(e,s,t){if(!Array.isArray(e))return[[e]];if(s||Array.isArray(e[0]))return e;if(t===1){let n=new Array(e.length);for(let o=0;o{if(a.push(...S),t===o-1){let C=Object.assign({},this.opts,e.opts);this.processBatchResults(a,C,e,A),s.close()}else setImmediate(()=>{this.executeBatchChunk(e,s,t+1,n,o,a,A,u)})},S=>{s.close(),u(S)}).catch(S=>{s.close(),u(S)})}processBatchResults(e,s,t,n){if(!e.length){n(s.metaAsArray?[[],[]]:[]);return}if(s.fullResult===void 0||s.fullResult){if(s.metaAsArray){let A=e.reduce((h,c)=>(Array.isArray(c[0])?h.push(...c[0]):c[0]instanceof ce?h.push(c[0]):h.push([c[0]]),h),[]),u=e[0][1];n([A,u])}else{let A=e.reduce((h,c)=>(c instanceof ce?h.push(c):!s.rowsAsArray&&Array.isArray(c[0])?h.push(...c[0]):h.push(c[0]),h),[]),u=e[0].meta;Object.defineProperty(A,"meta",{value:u,writable:!0,enumerable:s.metaEnumerable}),n(A)}return}(s.metaAsArray?e[0][0]:e[0])instanceof ce?this.aggregateOkPackets(e,s,n):this.aggregateResultSets(e,s,n)}aggregateOkPackets(e,s,t){let n=e[0].insertId,o=e[e.length-1].warningStatus,a=0;s.metaAsArray?(a=e.reduce((A,u)=>A+u[0].affectedRows,0),t([new ce(a,n,o),[]])):(a=e.reduce((A,u)=>A+u.affectedRows,0),t(new ce(a,n,o)))}aggregateResultSets(e,s,t){if(s.metaAsArray){let n=e.reduce((A,u)=>A+(u[0]?.length||0),0),o=new Array(n),a=0;for(let A of e)if(A[0]&&A[0].length){let u=A[0];for(let h=0;hu+(Array.isArray(h)?h.length:0),0),o=new Array(n),a=0;for(let u of e)if(Array.isArray(u)&&u.length)for(let h=0;h{n&&(clearTimeout(n),s())},o=>{n&&(clearTimeout(n),this._logAndReject(t,o))}),!0);return}this.addCommand(new Ui(e,s,t),!0)}reset(e,s,t){if(this.info.isMariaDB()&&this.info.hasMinVersion(10,2,4)||!this.info.isMariaDB()&&this.info.hasMinVersion(5,7,3)){let o=this,a=new L_(e,()=>{o.prepareCache&&o.prepareCache.reset(),Promise.resolve().then(o.handleCharset.bind(o)).then(o.handleTimezone.bind(o)).then(o.executeInitQuery.bind(o)).then(o.executeSessionTimeout.bind(o)).then(s).catch(t)},t);this.addCommand(a,!0);return}let n=new Error(`Reset command not permitted for server ${this.info.serverVersion.raw} (requires server MariaDB version 10.2.4+ or MySQL 5.7.3+)`);n.stack=e.stack,this._logAndReject(t,n)}isValid(){return this.status===5}end(e,s,t){if(this.addCommand=this.addCommandDisabled,clearTimeout(this.timeout),this.status<7&&this.status!==1){this.status=7;let n=()=>{this.status=8,this.socket.destroy(),this.socket.unref(),this.clear(),this.receiveQueue.clear(),s()},o=new di(e,n,n);this.sendQueue.push(o),this.receiveQueue.push(o);let a=typeof Deno<"u";this.sendQueue.length===1&&(a?this.nextSendCmd():process.nextTick(this.nextSendCmd.bind(this)))}else s()}destroy(){if(this.addCommand=this.addCommandDisabled,clearTimeout(this.timeout),this.status<7)if(this.status=7,this.sendQueue.clear(),this.receiveQueue.length>0){let e=this,s=this.socket.remoteAddress,t=s?Object.assign({},this.opts,{host:s}):this.opts,n=new E(t);n.connect().then(()=>{new Promise(n.query.bind(n,{sql:`KILL ${e.info.threadId}`})).finally(o=>{let a=w("Connection destroyed, command was killed",N.ER_CMD_NOT_EXECUTED_DESTROYED,e.info);if(e.opts.logger.error&&e.opts.logger.error(a),e.socketErrorDispatchToQueries(a),e.socket){let A=e.socket;process.nextTick(()=>{A.destroy()})}e.status=8,e.clear(),new Promise(n.end.bind(n)).catch(()=>{})})}).catch(()=>{let o=()=>{let A=e.socket;e.clear(),e.status=8,A.destroy(),e.receiveQueue.clear()},a=new di(o,o);e.sendQueue.push(a),e.receiveQueue.push(a),e.sendQueue.length===1&&(typeof Deno<"u"?e.nextSendCmd():process.nextTick(e.nextSendCmd.bind(e)))})}else this.status=8,this.socket.destroy(),this.clear()}pause(){this.socket.pause()}resume(){this.socket.resume()}format(e,s){let t=f('"Connection.format intentionally not implemented. please use Connection.query(sql, values), it will be more secure and faster',N.ER_NOT_IMPLEMENTED_FORMAT,this.info,"0A000");throw this.opts.logger.error&&this.opts.logger.error(t),t}serverVersion(){if(!this.info.serverVersion){let e=new Error("cannot know if server information until connection is established");throw this.opts.logger.error&&this.opts.logger.error(e),e}return this.info.serverVersion.raw}debug(e){typeof e=="boolean"?e?this.opts.logger.network||(this.opts.logger.network=console.log):this.opts.logger.network=null:typeof e=="function"&&(this.opts.logger.network=e),this.opts.emit("debug",e)}debugCompress(e){e?typeof e=="boolean"?(this.opts.debugCompress=e,e&&!this.opts.logger.network&&(this.opts.logger.network=console.log)):typeof e=="function"&&(this.opts.debugCompress=!0,this.opts.logger.network=e):this.opts.debugCompress=!1}get __tests(){return new Vi(this.info.collation,this.socket)}_canUseBulk(e,s){if(s&&s.fullResult&&(this.info.clientCapabilities&st)===0n)return!1;let t=s==null?this.opts.bulk:s.bulk!==void 0&&s.bulk!==null?s.bulk:this.opts.bulk;return!(this.info.serverVersion&&this.info.serverVersion.mariaDb&&this.info.hasMinVersion(10,2,7)&&(this.info.serverCapabilities&It)>0n)||!t?!1:e===void 0?!0:this.opts.namedPlaceholders?this._validateNamedParameters(e):this._validatePositionalParameters(e)}_validatePositionalParameters(e){let s=Array.isArray(e[0])?e[0].length:e[0]?1:0;if(s===0)return!1;for(let t of e){let n=Array.isArray(t)?t:[t];if(s!==n.length)return!1;for(let o of n)if(this._isStreamingValue(o))return!1}return!0}_validateNamedParameters(e){for(let s of e)for(let t of Object.values(s))if(this._isStreamingValue(t))return!1;return!0}_isStreamingValue(e){return e!=null&&typeof e=="object"&&typeof e.pipe=="function"&&typeof e.read=="function"}executeSessionVariableQuery(){if(this.opts.sessionVariables){let e=[],s="set ",t=Object.keys(this.opts.sessionVariables);if(t.length>0){for(let n=0;n{let o=w(`Error setting session variable (value ${JSON.stringify(this.opts.sessionVariables)}). Error: ${n.message}`,N.ER_SETTING_SESSION_ERROR,this.info,"08S01",s);return this.opts.logger.error&&this.opts.logger.error(o),Promise.reject(o)})}}return Promise.resolve()}handleCharset(){if(this.opts.collation){if(this.opts.collation.index<=255)return Promise.resolve();let s=this.opts.collation.charset==="utf8"&&this.opts.collation.maxLength===4?"utf8mb4":this.opts.collation.charset;return new Promise(this.query.bind(this,{sql:`SET NAMES ${s} COLLATE ${this.opts.collation.name}`}))}if(!this.opts.charset&&this.info.collation&&this.info.collation.charset==="utf8"&&this.info.collation.maxLength===4)return this.info.collation=P.fromCharset("utf8mb4"),Promise.resolve();let e=this.opts.charset?this.opts.charset:"utf8mb4";return this.info.collation=P.fromCharset(e),new Promise(this.query.bind(this,{sql:`SET NAMES ${e}`}))}handleTimezone(){let e=this;return this.opts.timezone==="local"&&(this.opts.timezone=void 0),this.opts.timezone==="auto"?new Promise(this.query.bind(this,{sql:"SELECT @@system_time_zone stz, @@time_zone tz"})).then(s=>{let t=s[0].tz==="SYSTEM"?s[0].stz:s[0].tz,n=Intl.DateTimeFormat().resolvedOptions().timeZone;return t===n||hs(t,e)===hs(n,e)?(this.opts.timezone=n,Promise.resolve()):this._setSessionTimezone(hs(n,e))}):this.opts.timezone?this._setSessionTimezone(hs(this.opts.timezone,e)):Promise.resolve()}_setSessionTimezone(e){return new Promise(this.query.bind(this,{sql:"SET time_zone=?",values:[e]})).catch(s=>{let t=f(`setting timezone '${e}' fails on server. look at https://mariadb.com/kb/en/mysql_tzinfo_to_sql/ to load IANA timezone. `,N.ER_WRONG_IANA_TIMEZONE,this.info,"08S01",null,!1,null,null,s);return Promise.reject(t)})}checkServerVersion(){return this.opts.forceVersionCheck?new Promise(this.query.bind(this,{sql:"SELECT @@VERSION AS v"})).then(function(e){return this.info.serverVersion.raw=e[0].v,this.info.serverVersion.mariaDb=this.info.serverVersion.raw.includes("MariaDB"),Lt.parseVersionString(this.info),Promise.resolve()}.bind(this)):Promise.resolve()}executeInitQuery(){if(this.opts.initSql){let e=Array.isArray(this.opts.initSql)?this.opts.initSql:[this.opts.initSql],s=[];return e.forEach(t=>{s.push(new Promise(this.query.bind(this,{sql:t})))}),Promise.all(s).catch(t=>{let n=w(`Error executing initial sql command: ${t.message}`,N.ER_INITIAL_SQL_ERROR,this.info);return this.opts.logger.error&&this.opts.logger.error(n),Promise.reject(n)})}return Promise.resolve()}executeSessionTimeout(){if(this.opts.queryTimeout)if(this.info.isMariaDB()&&this.info.hasMinVersion(10,1,2)){let e=`SET max_statement_time=${this.opts.queryTimeout/1e3}`;new Promise(this.query.bind(this,{sql:e})).catch(function(s){let t=w(`Error setting session queryTimeout: ${s.message}`,N.ER_INITIAL_TIMEOUT_ERROR,this.info,"08S01",e);return this.opts.logger.error&&this.opts.logger.error(t),Promise.reject(t)}.bind(this))}else{let e=f(`Can only use queryTimeout for MariaDB server after 10.1.1. queryTimeout value: ${this.opts.queryTimeout}`,N.ER_TIMEOUT_NOT_SUPPORTED,this.info,"HY000",this.opts.queryTimeout);return this.opts.logger.error&&this.opts.logger.error(e),Promise.reject(e)}return Promise.resolve()}getSocket(){return this.socket}streamInitSocket(){if(this.opts.connectTimeout&&(this.timeout=setTimeout(this.connectTimeoutReached.bind(this),this.opts.connectTimeout,Date.now())),this.opts.socketPath)this.socket=cs.default.connect(this.opts.socketPath);else if(this.opts.stream){if(typeof this.opts.stream=="function"){let e=this.opts.stream(function(s,t){if(s){this.authFailHandler(s);return}this.socket=t||cs.default.connect(this.opts.port,this.opts.host),this.socketInit()}.bind(this));e&&(this.socket=e,this.socketInit())}else this.authFailHandler(f("stream option is not a function. stream must be a function with (error, callback) parameter",N.ER_BAD_PARAMETER_VALUE,this.info));return}else this.socket=cs.default.connect(this.opts.port,this.opts.host),this.socket.setNoDelay(!0);this.socketInit()}socketInit(){this.socket.on("data",this.streamIn.onData.bind(this.streamIn)),this.socket.on("error",this.socketErrorHandler.bind(this)),this.socket.on("end",this.socketErrorHandler.bind(this)),this.socket.on("connect",function(){this.status===2&&(this.status=3,this.socket.setTimeout(this.opts.socketTimeout,this.socketTimeoutReached.bind(this)),this.opts.keepAliveDelay!==void 0&&(this.opts.keepAliveDelay>=0?this.socket.setKeepAlive(!0,this.opts.keepAliveDelay):this.socket.setKeepAlive(!0)))}.bind(this)),this.socket.writeBuf=e=>this.socket.write(e),this.socket.flush=()=>{},this.streamOut.setStream(this.socket)}authSucceedHandler(){this.opts.compress&&(this.info.serverCapabilities&Nt?(this.streamOut.setStream(new __(this.socket,this.opts,this.info)),this.streamIn=new i_(this.streamIn,this.receiveQueue,this.opts,this.info),this.socket.removeAllListeners("data"),this.socket.on("data",this.streamIn.onData.bind(this.streamIn))):this.opts.logger.error&&this.opts.logger.error(f("connection is configured to use packet compression, but the server doesn't have this capability",N.ER_COMPRESSION_NOT_SUPPORTED,this.info))),this.addCommand=this.opts.pipelining?this.addCommandEnablePipeline:this.addCommandEnable;let e=this;this.status=4,this.executeSessionVariableQuery().then(e.handleCharset.bind(e)).then(this.handleTimezone.bind(this)).then(this.checkServerVersion.bind(this)).then(this.executeInitQuery.bind(this)).then(this.executeSessionTimeout.bind(this)).then(()=>{clearTimeout(this.timeout),e.status=5,process.nextTick(e.connectResolveFct,e),e.waitingAuthenticationQueue.toArray().forEach(t=>{e.addCommand(t,!0)}),e.waitingAuthenticationQueue=null,e.connectRejectFct=null,e.connectResolveFct=null}).catch(s=>{if(s.fatal)e.authFailHandler.call(e,s);else{let t=()=>{e.authFailHandler.call(e,s)};e.end(t,t)}})}authFailHandler(e){clearTimeout(this.timeout),this.timeout=null,this.connectRejectFct&&(this.opts.logger.error&&this.opts.logger.error(e),this.receiveQueue.shift(),this.fatalError(e,!0),process.nextTick(this.connectRejectFct,e),this.connectRejectFct=null)}createSecureContext(e,s){e.requireValidCert=this.opts.ssl===!0||this.opts.ssl&&(this.opts.ssl.rejectUnauthorized===void 0||this.opts.ssl.rejectUnauthorized===!0);let t={socket:this.socket};typeof Deno<"u"?e.requireValidCert=!1:e.requireValidCert&&e.isMariaDB()&&!this.opts.socketPath&&this.opts.password&&!(this.opts.ssl&&this.opts.ssl.ca)&&(t.rejectUnauthorized=!1);let n=this.opts.ssl===!0?t:Object.assign({},this.opts.ssl,t);try{let o=y_.default.connect(n,s);o.on("data",this.streamIn.onData.bind(this.streamIn)),o.on("error",this.socketErrorHandler.bind(this)),o.on("end",this.socketErrorHandler.bind(this)),o.writeBuf=a=>o.write(a),o.flush=()=>{},this.socket.removeAllListeners("data"),this.socket=o,this.streamOut.setStream(o)}catch(o){this.socketErrorHandler(o)}}unexpectedPacket(e){if(e&&e.peek()===255){let s=e.readError(this.info);s.fatal&&this.status<6&&(this.status=6,this.emit("error",s),this.opts.logger.error&&this.opts.logger.error(s),this.end(()=>{},()=>{}))}else if(this.status<6){this.status=6;let s=w(`receiving packet from server without active commands conn:${this.info.threadId?this.info.threadId:-1}(${e.pos},${e.end}) ${ne(this.opts,e.buf,e.pos,e.end)}`,N.ER_UNEXPECTED_PACKET,this.info);this.opts.logger.error&&this.opts.logger.error(s),this.emit("error",s),this.destroy()}}connectTimeoutReached(e){this.timeout=null;let s=this.receiveQueue.peekFront(),t=w(`Connection timeout: failed to create socket after ${Date.now()-e}ms`,N.ER_CONNECTION_TIMEOUT,this.info,"08S01",null,s?s.stack:null);this.opts.logger.error&&this.opts.logger.error(t),this.authFailHandler(t)}socketTimeoutReached(){clearTimeout(this.timeout);let e=w("socket timeout",N.ER_SOCKET_TIMEOUT,this.info);this.opts.logger.error&&this.opts.logger.error(e),this.fatalError(e,!0)}addCommandQueue(e){this.waitingAuthenticationQueue.push(e)}addCommandEnable(e,s){e.once("end",this._boundSendNextCmd),this.sendQueue.isEmpty()&&this.receiveQueue.isEmpty()?(s&&this.receiveQueue.push(e),e.start(this.streamOut,this.opts,this.info)):(s&&this.receiveQueue.push(e),this.sendQueue.push(e))}addCommandEnablePipeline(e,s){e.once("send_end",this._boundSendNextCmd),s&&this.receiveQueue.push(e),this.sendQueue.isEmpty()?(e.start(this.streamOut,this.opts,this.info),e.sending&&(this.sendQueue.push(e),e.prependOnceListener("send_end",this.sendQueue.shift.bind(this.sendQueue)))):this.sendQueue.push(e)}addCommandDisabled(e){let s=e.throwNewError("Cannot execute new commands: connection closed",!0,this.info,"08S01",N.ER_CMD_CONNECTION_CLOSED);this.opts.logger.error&&this.opts.logger.error(s)}socketErrorHandler(e){if(!(this.status>=7))switch(this.socket&&(this.socket.writeBuf=()=>{},this.socket.flush=()=>{}),e?(e.fatal=!0,e.sqlState="HY000"):e=w("socket has unexpectedly been closed",N.ER_SOCKET_UNEXPECTED_CLOSE,this.info),this.status){case 2:case 3:let s=this.receiveQueue.peekFront();s&&s.stack&&e&&(e.stack+=` From event: `+s.stack.substring(s.stack.indexOf(` `)+1)),this.authFailHandler(e);break;default:this.fatalError(e,!1)}}fatalError(e,s){if(this.status>=6){this.socketErrorDispatchToQueries(e);return}let t=this.status!==2;this.status=7,this.addCommand=this.addCommandDisabled,this.socket&&(this.socket.removeAllListeners(),this.socket.destroyed||this.socket.destroy(),this.socket=void 0),this.status=8;let n=this.socketErrorDispatchToQueries(e);if(t){if(this.opts.logger.error&&this.opts.logger.error(e),this.listenerCount("error")>0)this.emit("error",e),this.emit("end"),this.clear();else if(this.emit("end"),this.clear(),!s&&!n)throw e}else this.clear()}socketErrorDispatchToQueries(e){let s,t=!1;for(;s=this.receiveQueue.shift();)s&&s.onPacketReceive&&(t=!0,setImmediate(s.throwError.bind(s,e,this.info)));return t}nextSendCmd(){let e;(e=this.sendQueue.shift())&&(e.sending?this.sendQueue.unshift(e):(e.start(this.streamOut,this.opts,this.info),e.sending&&(this.sendQueue.unshift(e),e.prependOnceListener("send_end",this.sendQueue.shift.bind(this.sendQueue)))))}changeTransaction(e,s,t){if(this.status>=6){let n=w("Cannot execute new commands: connection closed",N.ER_CMD_CONNECTION_CLOSED,this.info,"08S01",e.sql);this._logAndReject(t,n);return}if(this.receiveQueue.peekFront()||this.info.status&1){let n=new ge(s,this._logAndReject.bind(this,t),this.opts,e);this.addCommand(n,!0)}else s()}changeUser(e,s,t){if(!this.info.isMariaDB()){let o=f("method changeUser not available for MySQL server due to Bug #83472",N.ER_MYSQL_CHANGE_USER_BUG,this.info,"0A000");this._logAndReject(t,o);return}this.status<6&&(this.addCommand=this.addCommandEnable);let n=this;if(e.opts&&e.opts.collation&&typeof e.opts.collation=="string"){let o=e.opts.collation.toUpperCase();if(e.opts.collation=P.fromName(e.opts.collation.toUpperCase()),e.opts.collation===void 0)return t(new RangeError(`Unknown collation '${o}'`))}this.addCommand(new G_(e,this.opts,o=>{n.status<6&&n.opts.pipelining&&(n.addCommand=n.addCommandEnablePipeline),e.opts&&e.opts.collation&&(n.opts.collation=e.opts.collation),n.handleCharset().then(()=>{e.opts&&e.opts.collation&&(n.info.collation=e.opts.collation,n.opts.emit("collation",e.opts.collation)),s(o)}).catch(a=>{let A=()=>n.authFailHandler.call(n,a);a.fatal?A():n.end(A,A),t(a)})},this.authFailHandler.bind(this,t),this.getSocket.bind(this)),!0)}query(e,s,t){if(!e.sql)return t(f("sql parameter is mandatory",N.ER_UNDEFINED_SQL,this.info,"HY000",null,!1,e.stack));let n=new ge(s,o=>this._logAndReject(t,o),this.opts,e);this.addCommand(n,!0)}prepare(e,s,t){if(!e.sql){t(f("sql parameter is mandatory",N.ER_UNDEFINED_SQL,this.info,"HY000"));return}if(this.prepareCache&&(this.sendQueue.isEmpty()||!this.receiveQueue.peekFront())){let o=this.prepareCache.get(e.sql);if(o){s(o);return}}let n=new us(s,o=>this._logAndReject(t,o),this.opts,e,this);this.addCommand(n,!0)}prepareExecute(e,s,t){if(!e.sql){t(f("sql parameter is mandatory",N.ER_UNDEFINED_SQL,this.info,"HY000"));return}if(this.prepareCache&&(this.sendQueue.isEmpty()||!this.receiveQueue.peekFront())){let a=this.prepareCache.get(e.sql);if(a){this.executePromise(e,a,A=>{s(A),a.close()},A=>{t(A),a.close()});return}}let n=this;if(this.opts.pipelining&&this.info.isMariaDB()&&this.info.hasMinVersion(10,2,4)){let a=!1,A=e.values?Array.isArray(e.values)?e.values:[e.values]:[];for(let u=0;u{u++===0&&(h.prepare.close(),s(R))},R=>{u++===0&&(n.opts.logger.error&&n.opts.logger.error(R),t(R),h.prepare&&h.prepare.close())},n.opts,e,null);e.executeCommand=h;let c=new us(R=>{u>0&&R.close()},R=>{u++===0&&(n.opts.logger.error&&n.opts.logger.error(R),t(R))},n.opts,e,n);n.addCommand(c,!0),n.addCommand(h,!0);return}}let o=new us(a=>{n.executePromise(e,a,A=>{s(A),a.close()},A=>{n.opts.logger.error&&n.opts.logger.error(A),t(A),a.close()})},a=>{n.opts.logger.error&&n.opts.logger.error(a),t(a)},this.opts,e,n);n.addCommand(o,!0)}importFile(e,s,t){let n=this;if(!e||!e.file)return t(f("SQL file parameter is mandatory",N.ER_MISSING_SQL_PARAMETER,n.info,"HY000",null,!1,e.stack));let o=this.addCommand.bind(n);this.waitingAuthenticationQueue=new Dt.default,this.addCommand=this.addCommandQueue;let a=function(u,h,c){let R=new ge(h,I=>{n.opts.logger.error&&n.opts.logger.error(I),c(I)},n.opts,{sql:u,opts:{}});o(R,!0)},A=null;return(e.skipDbCheck?Promise.resolve():new Promise(a.bind(n,"SELECT DATABASE() as db"))).then(u=>(A=u?u[0].db:null,e.skipDbCheck&&!n.opts.database||!e.skipDbCheck&&!e.database&&!A?t(f("Database parameter is not set and no database is selected",N.ER_MISSING_DATABASE_PARAMETER,n.info,"HY000",null,!1,e.stack)):(e.database?new Promise(a.bind(n,`USE \`${e.database.replace(/`/gi,"``")}\``)):Promise.resolve()).then(()=>{let c=()=>{n.status<6&&(n.addCommand=n.addCommandEnable.bind(n),n.status<6&&n.opts.pipelining&&(n.addCommand=n.addCommandEnablePipeline.bind(n)),n.waitingAuthenticationQueue.toArray().forEach(I=>n.addCommand(I,!0)),n.waitingAuthenticationQueue=null)};return k_.promises.open(e.file,"r").then(async R=>{let I={buffer:Buffer.allocUnsafe(16384),offset:0,end:0},S=[],C=null;for(;!C;)try{let d=await R.read(I.buffer,I.end,I.buffer.length-I.end,null);if(d.bytesRead===0){if(R.close().catch(()=>{}),C){c(),t(C);return}await Promise.allSettled(S).then(()=>!e.skipDbCheck&&A&&e.database&&e.database!==A?new Promise(a.bind(n,`USE \`${A.replace(/`/gi,"``")}\``)):Promise.resolve()).then(()=>{c(),C?t(C):s()}).catch(b=>{c(),t(b)});return}else{I.end+=d.bytesRead;let g=Or(I).flatMap(U=>new Promise(a.bind(n,U)).catch(M=>{C=M}));if(S.push(...g),I.offset===I.end)I.offset=0,I.end=0;else if(I.offset>8192)I.buffer.copy(I.buffer,0,I.offset,I.end),I.end-=I.offset,I.offset=0;else if(I.buffer.length-I.end<8192){let U=Buffer.allocUnsafe(I.buffer.length<<1);I.buffer.copy(U,0,I.offset,I.end),I.buffer=U,I.end-=I.offset,I.offset=0}}}catch(d){return R.close().catch(()=>{}),c(),Promise.allSettled(S).catch(()=>{}),t(f(d.message,N.ER_SQL_FILE_ERROR,n.info,"HY000",null,!1,e.stack))}C&&(c(),t(C))}).catch(R=>(c(),R.code==="ENOENT"?t(f(`SQL file parameter '${e.file}' doesn't exists`,N.ER_MISSING_SQL_FILE,n.info,"HY000",null,!1,e.stack)):t(f(R.message,N.ER_SQL_FILE_ERROR,n.info,"HY000",null,!1,e.stack))))})))}clear(){this.sendQueue.clear(),this.opts.removeAllListeners(),this.streamOut=void 0,this.socket=void 0}redirect(e,s){if(this.opts.permitRedirect&&e)if(this.receiveQueue.length<=1&&(this.info.status&1)===0){this.info.redirectRequest=null;let t=e.match(jo);if(!t)return this.opts.logger.error&&this.opts.logger.error(new Error("error parsing redirection string "+e+". format must be 'mariadb/mysql://[[:]@][:]/[[?=[&=]]]'")),s();let n={host:t[7]?decodeURIComponent(t[7]):t[6],port:t[9]?parseInt(t[9]):3306};if(n.host===this.opts.host&&n.port===this.opts.port)return s();t[3]&&(n.user=t[3]),t[5]&&(n.password=t[5]);let o=fe.parseOptionDataType(n),a=new fe(Object.assign({},this.opts,o)),A=new E(a);A.connect().then(async function(){await new Promise(this.end.bind(this,{})),this.status=5,this.info=A.info,this.opts=A.opts,this.socket=A.socket,this.prepareCache&&this.prepareCache.reset(),this.streamOut=A.streamOut,this.streamIn=A.streamIn,s()}.bind(this)).catch(function(u){if(this.opts.logger.error){let h=new Error(`fail to redirect to '${e}'`);h.cause=u,this.opts.logger.error(h)}s()}.bind(this))}else this.info.redirectRequest=e,s();else this.info.redirectRequest=null,s()}get threadId(){return this.info?this.info.threadId:null}_sendNextCmdImmediate(){this.sendQueue.isEmpty()||this.nextSendCmd()}_closePrepare(e){this.addCommand(new b_({},()=>{},()=>{},e),!1)}_logAndReject(e,s){this.opts.logger.error&&this.opts.logger.error(s),e(s)}},Vi=class{#e;#t;constructor(e,s){this.#e=e,this.#t=s}getCollation(){return this.#e}getSocket(){return this.#t}},wt=xi;var Yi=class extends x_.EventEmitter{opts;#e=!1;#t=!1;#s=null;#i;#r={};#_=new Wi.default;#o;#n;#A=0;#u=!1;#a;#E;constructor(e){super(),this.opts=e,this.#i=new Wi.default(null,{capacity:this.opts.connectionLimit}),this.on("_idle",this._processNextPendingRequest),this.on("validateSize",this._managePoolSize),this._managePoolSize()}_managePoolSize(){if(!this._shouldCreateMoreConnections()||this.#a)return;this.#t=!0;let e=Date.now()+this.opts.initializationTimeout;this._initiateConnectionCreation(e)}_initiateConnectionCreation(e){this._createPoolConnection(()=>this._onConnectionCreationSuccess(),s=>this._onConnectionCreationError(s,e),e)}_onConnectionCreationSuccess(){this.#u=!0,this.#s=null,this.#A=0,this.#E=null,this._shouldCreateMoreConnections()&&this.emit("validateSize"),this._startConnectionReaping()}_onConnectionCreationError(e,s){if(this.#t=!1,this.#e)return;this.#s&&(e=this.#s);let t;this.#u?t=f("Pool fails to create connection",N.ER_POOL_NO_CONNECTION,null,null,null,!1,null,null,e):t=f("Error during pool initialization",N.ER_POOL_NOT_INITIALIZED,null,null,null,!1,null,null,e);let n=Math.min(++this.#A*200,1e4);this._scheduleRetryWithBackoff(n),this.emit("error",t)}_scheduleRetryWithBackoff(e){this.#e||(this.#a=setTimeout(()=>{this.#a=null,this.#_.isEmpty()||this._managePoolSize()},e))}_createPoolConnection(e,s,t){if(this.#e){this.#E=null;return}let n=Object.assign({},this.opts.connOptions,{connectTimeout:Math.max(1,Math.min(t-Date.now(),this.opts.connOptions.connectTimeout||Number.MAX_SAFE_INTEGER))}),o=new wt(n);this.#E=null,o.connect().then(a=>this._prepareNewConnection(a,e,s)).catch(a=>this._handleConnectionCreationError(a,e,s,t))}_prepareNewConnection(e,s,t){if(this.#e){this._cleanupConnection(e,"pool_closed"),t(new w("Cannot create new connection to pool, pool closed",N.ER_ADD_CONNECTION_CLOSED_POOL));return}e.lastUse=Date.now(),e.forceEnd=e.end,e.release=n=>this._handleRelease(e,n),e.end=e.release,this._overrideConnectionMethods(e),this._setupConnectionErrorHandler(e),this.#i.push(e),this.#t=!1,this.emit("_idle"),s(e),setImmediate(()=>this._onNewConnection(e))}_onNewConnection(e){}_overrideConnectionMethods(e){let s=e.destroy.bind(e),t=this;e.destroy=function(){t._endLeak(e),delete t.#r[e.threadId],s(),t.emit("validateSize")}}_setupConnectionErrorHandler(e){let s=this;e.on("error",()=>{s._endLeak(e),delete s.#r[e.threadId],s._processIdleConnectionsOnError(e),setImmediate(()=>{s.#_.isEmpty()||s._managePoolSize()})})}_processIdleConnectionsOnError(e){let s=0;for(;sthis._createPoolConnection(s,t,n),Math.min(500,n-Date.now()))}_checkRequestTimeouts(){this.#n=null;let e=Date.now();for(;this.#_.length>0;){let s=this.#_.peekFront();if(this._hasRequestTimedOut(s,e)){this._rejectTimedOutRequest(s,e);continue}this._scheduleNextTimeoutCheck(s,e);return}}_hasRequestTimedOut(e,s){return e.timeout<=s}_rejectTimedOutRequest(e,s){this.#_.shift();let t=this.activeConnections()===0?this.#s:null,n=Math.abs(s-(e.timeout-this.opts.acquireTimeout)),o;t?o=f(`pool failed to retrieve a connection from pool${this._errorMsgAddon()}`,N.ER_GET_CONNECTION_TIMEOUT,null,"HY000",null,!1,e.stack,null,t):o=f(`pool timeout: failed to retrieve a connection from pool after ${n}ms${this._errorMsgAddon()}`,N.ER_GET_CONNECTION_TIMEOUT,null,"HY000",null,!1,e.stack,null,null),e.reject(o)}_scheduleNextTimeoutCheck(e,s){let t=e.timeout-s;this.#n=setTimeout(()=>this._checkRequestTimeouts(),t)}_destroy(e){this._endLeak(e),delete this.#r[e.threadId],e.lastUse=Date.now(),e.forceEnd(null,()=>{},()=>{}),this.totalConnections()===0&&this._stopConnectionReaping(),this.emit("validateSize")}release(e){if(this.#r[e.threadId]){if(this._endLeak(e),e.lastUse=Date.now(),this.#e){delete this.#r[e.threadId],this._cleanupConnection(e,"pool_closed");return}e.isValid()?(this.emit("release",e),delete this.#r[e.threadId],this.#i.push(e),process.nextTick(this.emit.bind(this,"_idle"))):this._cleanupConnection(e,"validation_failed")}}_endLeak(e){e.leakProcess&&(clearTimeout(e.leakProcess),e.leakProcess=null,e.leaked&&e.opts.logger.warning(`Previous possible leak connection with thread ${e.info.threadId} was returned to pool`))}_startConnectionReaping(){!this.#o&&this.opts.idleTimeout>0&&(this.#o=setInterval(this._removeIdleConnections.bind(this),500))}_stopConnectionReaping(){this.#o&&this.totalConnections()===0&&(clearInterval(this.#o),this.#o=null)}_removeIdleConnections(){let e=Date.now()-this.opts.idleTimeout*1e3,s=Math.max(0,this.#i.length-this.opts.minimumIdle);for(;s>0;){let t=this.#i.peek();if(s--,t&&t.lastUse{},()=>{});continue}break}this.totalConnections()===0&&this._stopConnectionReaping(),this.emit("validateSize")}_shouldCreateMoreConnections(){let e=this.#_.length>0,s=this.totalConnections()0&&this._startLeakDetection(s),this.#r[s.threadId]=s,this.emit("acquire",s),e.resolver(s)):this.#_.unshift(e),this._checkRequestTimeouts()}_hasIdleConnection(){return!this.#i.isEmpty()}_acquireIdleConnection(e){if(!this._hasIdleConnection()||this.#e){e(new Error("No idle connections available"));return}this._findValidIdleConnection(e,!1)}_searchInfo(){let e=null,s=this.#i.get(0);if(!s){for(let t in Object.keys(this.#r))if(s=this.#r[t],!s)break}return s&&(e=s.info),e}_findValidIdleConnection(e,s){if(this.#i.isEmpty()){s&&setImmediate(()=>this.emit("validateSize")),e(new Error("No valid connections found"));return}let t=this.#i.shift();this.#r[t.threadId]=t,this._validateConnectionHealth(t,n=>{if(n){this.opts.leakDetectionTimeout>0&&this._startLeakDetection(t),s&&setImmediate(()=>this.emit("validateSize")),e(null,t);return}else delete this.#r[t.threadId];this._findValidIdleConnection(e,!0)})}_validateConnectionHealth(e,s){if(!e){s(!1);return}let t=this.opts.minDelayValidation>0&&Date.now()-e.lastUse<=this.opts.minDelayValidation;if(!e.isValid()||t){s(e.isValid());return}let n={opts:{timeout:this.opts.pingTimeout}};e.ping(n,()=>s(!0),()=>s(!1))}_leakedConnections(){let e=0;for(let s of Object.values(this.#r))s&&s.leaked&&e++;return e}_errorMsgAddon(){return this.opts.leakDetectionTimeout>0?` (pool connections: active=`+this.activeConnections()+" idle="+this.idleConnections()+" leak="+this._leakedConnections()+" limit="+this.opts.connectionLimit+")":` (pool connections: active=${this.activeConnections()} idle=${this.idleConnections()} limit=${this.opts.connectionLimit})`}toString(){return`active=${this.activeConnections()} idle=${this.idleConnections()} limit=${this.opts.connectionLimit}`}get closed(){return this.#e}totalConnections(){return this.activeConnections()+this.idleConnections()}activeConnections(){return Object.keys(this.#r).length}idleConnections(){return this.#i.length}taskQueueSize(){return this.#_.length}escape(e){return Ot(this.opts.connOptions,this._searchInfo(),e)}escapeId(e){return Zt(this.opts.connOptions,this._searchInfo(),e)}getConnection(e,s){if(typeof e=="function"&&(s=e,e={}),this.#e){let t=f("pool is closed",N.ER_POOL_ALREADY_CLOSED,null,"HY000",e===null?null:e.sql,!1,e.stack);s(t);return}this._acquireIdleConnection((t,n)=>{if(!t&&n){this.emit("acquire",n),s(null,n);return}if(this.#e){s(f("Cannot add request to pool, pool is closed",N.ER_POOL_ALREADY_CLOSED,null,"HY000",e===null?null:e.sql,!1,e.stack));return}setImmediate(this.emit.bind(this,"validateSize")),setImmediate(this.emit.bind(this,"enqueue"));let o=new Ki(Date.now()+this.opts.acquireTimeout,e.stack,a=>s(null,a),a=>s(a));this.#_.push(o),this.#n||(this.#n=setTimeout(this._checkRequestTimeouts.bind(this),this.opts.acquireTimeout))})}end(){if(this.#e)return Promise.reject(f("pool is already closed",N.ER_POOL_ALREADY_CLOSED));this.#e=!0,clearInterval(this.#o),clearInterval(this.#a),clearTimeout(this.#E),clearTimeout(this.#n),this.#o=null,this.#a=null,this.#E=null,this.#n=null;let e={};this.opts.trace&&Error.captureStackTrace(e);let s=[],t;for(;t=this.#i.shift();)s.push(new Promise(t.forceEnd.bind(t,e)));if(!this.#_.isEmpty()){let o=f("pool is ending, connection request aborted",N.ER_CLOSING_POOL,null,"HY000",null,!1,e.stack),a;for(;a=this.#_.shift();)a.reject(o)}this.removeAllListeners();let n=this;return Promise.all(s).then(async()=>{if(n.activeConnections()>0){let o=100;for(;o-- >0;)n.activeConnections()>0&&await new Promise(a=>setTimeout(()=>a(),100));for(let a of Object.values(n.#r))a&&a.destroy()}return Promise.resolve()})}_cleanupConnection(e,s=""){if(e){this._endLeak(e),delete this.#r[e.threadId];try{(e.forceEnd?e.forceEnd:e.end).call(e,null,()=>this.emit("connectionClosed",{threadId:e.threadId,reason:s}),()=>{})}catch(t){this.emit("error",new Error(`Failed to cleanup connection: ${t.message}`))}this.totalConnections()===0&&this._stopConnectionReaping(),this.emit("validateSize")}}_handleRelease(e,s){if(s=s||function(){},this.#e||!e.isValid()){this._destroy(e),s();return}if(this.opts.noControlAfterUse){this.release(e),s();return}this._getRevertFunction(e)(n=>{n?this._destroy(e):this.release(e),s()})}_getRevertFunction(e){return this.opts.resetAfterUse&&e.info.isMariaDB()&&(e.info.serverVersion.minor===2&&e.info.hasMinVersion(10,2,22)||e.info.hasMinVersion(10,3,13))?t=>e.reset({},t):t=>e.changeTransaction({sql:"ROLLBACK"},()=>t(null),n=>t(n))}_startLeakDetection(e){e.lastUse=Date.now(),e.leaked=!1,e.leakProcess=setTimeout(()=>{e.leaked=!0;let s=Date.now()-e.lastUse;e.opts.logger.warning(`A possible connection leak on thread ${e.info.threadId} (connection not returned to pool for ${s}ms). Has connection.release() been called?${this._errorMsgAddon()}`)},this.opts.leakDetectionTimeout,e)}},Ki=class{constructor(e,s,t,n){this.timeout=e,this.stack=s,this.resolver=t,this.rejecter=n}reject(e){process.nextTick(this.rejecter,e)}},ls=Yi;var vi=class extends V_.EventEmitter{#e;constructor(e){super(),this.#e=new ls(e);let s=this;this.#e._onNewConnection=t=>{try{s.emit("connection",new be(t))}catch{}},this.#e.on("acquire",this.emit.bind(this,"acquire")),this.#e.on("enqueue",this.emit.bind(this,"enqueue")),this.#e.on("release",this.emit.bind(this,"release")),this.#e.on("error",this.emit.bind(this,"error"))}#t=()=>{};get closed(){return this.#e.closed}totalConnections(){return this.#e.totalConnections()}activeConnections(){return this.#e.activeConnections()}idleConnections(){return this.#e.idleConnections()}taskQueueSize(){return this.#e.taskQueueSize()}escape(e){return this.#e.escape(e)}escapeId(e){return this.#e.escapeId(e)}end(e){this.#e.end().then(()=>{e&&e(null)}).catch(e||this.#t)}getConnection(e){if(!e)throw new f("missing mandatory callback parameter",N.ER_MISSING_PARAMETER);let s={};this.#e.opts.connOptions.trace&&Error.captureStackTrace(s),this.#e.getConnection(s,(t,n)=>{if(t)e(t);else{let o=new be(n);o.end=a=>o.release(a),o.close=a=>o.release(a),e(null,o)}})}query(e,s,t){let n=be._PARAM(this.#e.opts.connOptions,e,s,t);this.#e.getConnection(n,(o,a)=>{if(o)n.callback&&n.callback(o);else{let A=n.callback;n.callback=(u,h,c)=>{this.#e.release(a),A&&A(u,h,c)},be._QUERY_CMD(a,n)}})}execute(e,s,t){let n=be._PARAM(this.#e.opts.connOptions,e,s,t);this.#e.getConnection(n,(o,a)=>{if(o)n.callback&&n.callback(o);else{let A=n.callback;a.prepareExecute(n,u=>{this.#e.release(a),A&&A(null,u,u.meta)},u=>{this.#e.release(a),A&&A(u)})}})}batch(e,s,t){let n=be._PARAM(this.#e.opts.connOptions,e,s,t);this.#e.getConnection(n,(o,a)=>{if(o)n.callback&&n.callback(o);else{let A=n.callback;a.batch(n,u=>{this.#e.release(a),A&&A(null,u)},u=>{this.#e.release(a),A&&A(u)})}})}importFile(e,s){if(!e){s&&s(f("SQL file parameter is mandatory",N.ER_MISSING_SQL_PARAMETER,null,"HY000",null,!1,null));return}this.#e.getConnection({},(t,n)=>{t?s&&s(t):n.importFile({file:e.file,database:e.database},o=>{this.#e.release(n),s&&s(null,o)},o=>{this.#e.release(n),s&&s(o)})})}toString(){return"poolCallback("+this.#e.toString()+")"}},gt=vi;var K_=require("node:events");var W_=require("node:stream"),Qi=class extends ge{constructor(e,s,t){super(()=>{},()=>{},s,e),this.socket=t,this.inStream=new W_.Readable({objectMode:!0,read:()=>{this.socket.resume()}}),this.on("fields",function(n){this.inStream.emit("fields",n)}),this.on("error",function(n){this.inStream.emit("error",n)}),this.on("close",function(n){this.inStream.emit("error",n)}),this.on("end",function(n){n&&this.inStream.emit("error",n),this.socket.resume(),this.inStream.push(null)}),this.inStream.close=function(){this.handleNewRows=()=>{},this.socket.resume()}.bind(this)}handleNewRows(e){this.inStream.push(e)||this.socket.pause()}},Y_=Qi;var Ns=class{#e;#t;constructor(e){this.#e=e,this.#t=e.opts.trace?Error.captureStackTrace:()=>{}}get threadId(){return this.#e.threadId}get info(){return this.#e.info}get prepareCache(){return this.#e.prepareCache}changeUser(e){let s={opts:e};return this.#t(s),new Promise(this.#e.changeUser.bind(this.#e,s))}beginTransaction(){let e={sql:"START TRANSACTION"};return this.#t(e),new Promise(this.#e.query.bind(this.#e,e))}commit(){let e={sql:"COMMIT"};return this.#t(e),new Promise(this.#e.changeTransaction.bind(this.#e,e))}rollback(){let e={sql:"ROLLBACK"};return this.#t(e),new Promise(this.#e.changeTransaction.bind(this.#e,e))}query(e,s){let t=Ye(e,s);return this.#t(t),new Promise(this.#e.query.bind(this.#e,t))}queryStream(e,s){let t=Ye(e,s);this.#t(t);let n=new Y_(t,this.#e.opts,this.#e.socket);return this.#e.opts.logger.error&&n.on("error",this.#e.opts.logger.error),this.#e.addCommand(n,!0),n.inStream}static _PARAM_DEF(e,s){return typeof e=="object"?{sql:e.sql,values:e.values?e.values:s,opts:e}:{sql:e,values:s}}execute(e,s){let t=Ye(e,s);return this.#t(t),new Promise(this.#e.prepareExecute.bind(this.#e,t))}static _EXECUTE_CMD(e,s){return e.prepareExecute(s)}prepare(e){let s;return typeof e=="object"?s={sql:e.sql,opts:e}:s={sql:e},this.#t(s),new Promise(this.#e.prepare.bind(this.#e,s))}batch(e,s){let t=Ye(e,s);return this.#t(t),new Promise(this.#e.batch.bind(this.#e,t))}importFile(e){return!e||!e.file?Promise.reject(f("SQL file parameter is mandatory",N.ER_MISSING_SQL_PARAMETER,this.#e.info,"HY000",null,!1,null)):new Promise(this.#e.importFile.bind(this.#e,{file:e.file,database:e.database}))}ping(e){let s={opts:{timeout:e}};return this.#t(s),new Promise(this.#e.ping.bind(this.#e,s))}reset(){let e={};return this.#t(e),new Promise(this.#e.reset.bind(this.#e,e))}isValid(){return this.#e.isValid()}end(){let e={};return this.#t(e),new Promise(this.#e.end.bind(this.#e,e))}close(){this.destroy()}destroy(){this.#e.destroy()}pause(){this.#e.pause()}resume(){this.#e.resume()}format(e,s){this.#e.format(e,s)}serverVersion(){return this.#e.serverVersion()}debug(e){return this.#e.debug(e)}debugCompress(e){return this.#e.debugCompress(e)}escape(e){return this.#e.escape(e)}escapeId(e){return this.#e.escapeId(e)}on(e,s){return this.#e.on.call(this.#e,e,s),this}off(e,s){return this.#e.off.call(this.#e,e,s),this}once(e,s){return this.#e.once.call(this.#e,e,s),this}listeners(e){return this.#e.listeners.call(this.#e,e)}addListener(e,s){return this.#e.addListener.call(this.#e,e,s),this}eventNames(){return this.#e.eventNames.call(this.#e)}getMaxListeners(){return this.#e.getMaxListeners.call(this.#e)}listenerCount(e,s){return this.#e.listenerCount.call(this.#e,e,s)}prependListener(e,s){return this.#e.prependListener.call(this.#e,e,s),this}prependOnceListener(e,s){return this.#e.prependOnceListener.call(this.#e,e,s),this}removeAllListeners(e,s){return this.#e.removeAllListeners.call(this.#e,e,s),this}removeListener(e,s){return this.#e.removeListener.call(this.#e,e,s),this}setMaxListeners(e){return this.#e.setMaxListeners.call(this.#e,e),this}rawListeners(e){return this.#e.rawListeners.call(this.#e,e)}get __tests(){return this.#e.__tests}};typeof Symbol.asyncDispose=="symbol"&&(Ns.prototype[Symbol.asyncDispose]=function(){return this.end()});var qi=Ns,Ye=function(E,e){return typeof E=="object"?{sql:E.sql,values:E.values?E.values:e,opts:E}:{sql:E,values:e}};var v_=typeof Symbol.asyncDispose=="symbol",Is=class extends K_.EventEmitter{#e;constructor(e){super(),this.#e=new ls(e);let s=this;this.#e._onNewConnection=t=>{try{s.emit("connection",new qi(t))}catch{}},this.#e.on("acquire",this.emit.bind(this,"acquire")),this.#e.on("enqueue",this.emit.bind(this,"enqueue")),this.#e.on("release",this.emit.bind(this,"release")),this.#e.on("error",this.emit.bind(this,"error"))}get closed(){return this.#e.closed}totalConnections(){return this.#e.totalConnections()}activeConnections(){return this.#e.activeConnections()}idleConnections(){return this.#e.idleConnections()}taskQueueSize(){return this.#e.taskQueueSize()}escape(e){return this.#e.escape(e)}escapeId(e){return this.#e.escapeId(e)}end(){return this.#e.end()}async getConnection(){let e={};return this.#e.opts.connOptions.trace&&Error.captureStackTrace(e),new Promise((s,t)=>{this.#e.getConnection(e,(n,o)=>{if(n)t(n);else{let a=new qi(o);a.release=()=>new Promise(o.release),a.end=a.release,a.close=a.release,v_&&(a[Symbol.asyncDispose]=()=>a.release()),s(a)}})})}query(e,s){let t=Ye(e,s);return this.#e.opts.connOptions.trace&&Error.captureStackTrace(t),new Promise((n,o)=>this.#e.getConnection(t,(a,A)=>{a?o(a):A.query(t,u=>{this.#e.release(A),n(u)},u=>{this.#e.release(A),o(u)})}))}execute(e,s){let t=Ye(e,s);return this.#e.opts.connOptions.trace&&Error.captureStackTrace(t),new Promise((n,o)=>this.#e.getConnection(t,(a,A)=>{a?o(a):A.prepareExecute(t,u=>{this.#e.release(A),n(u)},u=>{this.#e.release(A),o(u)})}))}batch(e,s){let t=Ye(e,s);return this.#e.opts.connOptions.trace&&Error.captureStackTrace(t),new Promise((n,o)=>this.#e.getConnection(t,(a,A)=>{a?o(a):A.batch(t,u=>{this.#e.release(A),n(u)},u=>{this.#e.release(A),o(u)})}))}importFile(e){return e?new Promise((s,t)=>this.#e.getConnection({},(n,o)=>{n?t(n):o.importFile({file:e.file,database:e.database},a=>{this.#e.release(o),s(a)},a=>{this.#e.release(o),t(a)})})):Promise.reject(f("SQL file parameter is mandatory",N.ER_MISSING_SQL_PARAMETER,null,"HY000",null,!1,null))}toString(){return"poolPromise("+this.#e.toString()+")"}};v_&&(Is.prototype[Symbol.asyncDispose]=function(){return this.end()});var Q_=Is;var Xi=class{#e;#t;#s;constructor(e,s,t){this.#e=e,this.#t=s,this.#s=t}getConnection(){return this.#e.getConnection(this.#t,this.#s)}query(e,s){return this.#e.getConnection(this.#t,this.#s).then(t=>t.query(e,s).then(n=>(t.release(),n)).catch(n=>(t.release(),Promise.reject(n)))).catch(t=>Promise.reject(t))}execute(e,s){return this.#e.getConnection(this.#t,this.#s).then(t=>t.execute(e,s).then(n=>(t.release(),n)).catch(n=>(t.release(),Promise.reject(n)))).catch(t=>Promise.reject(t))}batch(e,s){return this.#e.getConnection(this.#t,this.#s).then(t=>t.batch(e,s).then(n=>(t.release(),n)).catch(n=>(t.release(),Promise.reject(n)))).catch(t=>Promise.reject(t))}},q_=Xi;var ji=class{#e;#t;#s;constructor(e,s,t){this.#e=e,this.#t=s,this.#s=t}getConnection(e){let s=e||((t,n)=>{});return this.#e.getConnection(this.#t,this.#s,s)}query(e,s,t){let n=e,o=s,a=t;typeof s=="function"&&(o=null,a=s);let A=a||(()=>{});this.getConnection((u,h)=>{u?A(u):h.query(n,o,(c,R,I)=>{h.release(()=>{}),c?A(c):A(null,R,I)})})}execute(e,s,t){let n=e,o=s,a=t;typeof s=="function"&&(o=null,a=s);let A=a||(()=>{});this.getConnection((u,h)=>{u?A(u):h.execute(n,o,(c,R,I)=>{h.release(()=>{}),c?A(c):A(null,R,I)})})}batch(e,s,t){let n=e,o=s,a=t;typeof s=="function"&&(o=null,a=s);let A=a||(()=>{});this.getConnection((u,h)=>{u?A(u):h.batch(n,o,(c,R,I)=>{h.release(()=>{}),c?A(c):A(null,R,I)})})}},X_=ji;var j_=m(require("node:events"),1),$i=class extends j_.default{#e;#t={};#s={};#i=0;constructor(e){super(),this.#e=new Xt(e)}add(e,s){let t;if(typeof e=="string"||e instanceof String){if(t=e,this.#t[t])throw new Error(`Node identifier '${t}' already exist !`)}else t="PoolNode-"+this.#i++,s=e;let n=new jt(s);this.#t[t]=this._createPool(n)}end(){let e=this;this.#s={};let s=[];return Object.keys(this.#t).forEach(t=>{let n=e.#t[t].end();n&&s.push(n)}),this.#t=null,Promise.all(s)}of(e,s){return new q_(this,e,s)}_ofCallback(e,s){return new X_(this,e,s)}remove(e){if(!e)throw new Error("pattern parameter in Cluster.remove(pattern) is mandatory");let s=RegExp(e);Object.keys(this.#t).forEach(function(t){s.test(t)&&(this.#t[t].end(),delete this.#t[t],this.#s={})}.bind(this))}getConnection(e,s){return this._getConnection(e,s,void 0,void 0,void 0)}_setCallback(){this.getConnection=this._getConnectionCallback,this._createPool=this._createPoolCallback,this.of=this._ofCallback}_getConnection(e,s,t,n,o){let a=this._matchingNodes(e||/^/);if(a.length===0){if(Object.keys(this.#t).length===0&&!o)return Promise.reject(new Error("No node have been added to cluster or nodes have been removed due to too much connection error"));if(n===void 0)return Promise.reject(new Error(`No node found for pattern '${e}'`));let u=`No Connection available for '${e}'${o?". Last connection error was: "+o.message:""}`;return Promise.reject(new Error(u))}t===void 0&&(t=a.length);let A=--t>=0?this._getConnection.bind(this,e,s,t):null;try{let u=this._selectPool(a,s,n);return this._handleConnectionError(a,u,A)}catch(u){return Promise.reject(u)}}_createPool(e){let s=new Q_(e);return s.on("error",t=>{}),s}_createPoolCallback(e){let s=new gt(e);return s.on("error",t=>{}),s}_getConnectionCallback(e,s,t,n,o,a){let A=this._matchingNodes(e||/^/);if(A.length===0){if(Object.keys(this.#t).length===0&&!a){t(new Error("No node have been added to cluster or nodes have been removed due to too much connection error"));return}o===void 0&&t(new Error(`No node found for pattern '${e}'`));let h=`No Connection available for '${e}'${a?". Last connection error was: "+a.message:""}`;t(new Error(h));return}n===void 0&&(n=A.length);let u=--n>=0?this._getConnectionCallback.bind(this,e,s,t,n):null;try{let h=this._selectPool(A,s,o);this._handleConnectionCallbackError(A,h,u,t)}catch(h){t(h)}}_matchingNodes(e){if(this.#s[e])return this.#s[e];let s=RegExp(e),t=[];return Object.keys(this.#t).forEach(n=>{s.test(n)&&t.push(n)}),this.#s[e]=t,t}_selectPool(e,s,t){let n=s||this.#e.defaultSelector,o;switch(n){case"RR":o=$o;break;case"RANDOM":o=Zo;break;case"ORDER":o=Jo;break;default:throw new Error(`Wrong selector value '${n}'. Possible values are 'RR','RANDOM' or 'ORDER'`)}let a=0,A=o(e,a);for(;(t===A||this.#t[A].blacklistedUntil&&this.#t[A].blacklistedUntil>Date.now())&&a=n.#e.removeNodeErrorCount&&n.#t[e]&&(delete n.#t[e],n.#s={},delete s.lastRrIdx,setImmediate(n.emit.bind(n,"remove",e)),t instanceof gt?t.end(()=>{}):t.end().catch(o=>{}))}_handleConnectionError(e,s,t){let n=this,o=this.#t[s];return o.getConnection().then(a=>(o.blacklistedUntil=null,o.errorCount=0,a)).catch(a=>(this._handleNodeFailure(s,e),e.length!==0&&n.#e.canRetry&&t?t(s,a):Promise.reject(a)))}_handleConnectionCallbackError(e,s,t,n){let o=this,a=this.#t[s];a.getConnection((A,u)=>{if(A){if(this._handleNodeFailure(s,e),e.length!==0&&o.#e.canRetry&&t)return t(s,A);n(A)}else a.blacklistedUntil=null,a.errorCount=0,n(null,u)})}get __tests(){return new Zi(this.#t)}},Zi=class{#e;constructor(e){this.#e=e}getNodes(){return this.#e}},$o=E=>{let e=E.lastRrIdx;return e===void 0&&(e=-1),++e>=E.length&&(e=0),E.lastRrIdx=e,E[e]},Zo=E=>{let e=Math.floor(Math.random()*E.length);return E[e]},Jo=(E,e)=>E[e],$_=$i;var Ji=class{#e;constructor(e){this.#e=new $_(e),this.#e._setCallback(),this.on=this.#e.on.bind(this.#e),this.once=this.#e.once.bind(this.#e)}end(e){if(e&&typeof e!="function")throw new Error("callback parameter must be a function");let s=e||(()=>{});this.#e.end().then(()=>{s()}).catch(s)}getConnection(e,s,t){let n=e,o=s,a=t;typeof e=="function"?(n=null,o=null,a=e):typeof s=="function"&&(o=null,a=s);let A=a||((u,h)=>{});this.#e.getConnection(n,o,A)}add(e,s){this.#e.add(e,s)}of(e,s){return this.#e.of(e,s)}remove(e){this.#e.remove(e)}get __tests(){return this.#e.__tests}},Z_=Ji;var J_=Be.version;function z_(E){let e=new fe(E),s={};for(let[t,n]of Object.entries(e))t.startsWith("_")||(s[t]=n);return s}function en(E){let e=new wt(new fe(E)),s=new be(e);return e.connect().then(function(){e.emit("connect")}.bind(e)).catch(e.emit.bind(e,"connect")),s}function tn(E){let e=new jt(E),s=new gt(e);return s.on("error",t=>{}),s}function sn(E){let e=new Xt(E);return new Z_(e)}function rn(E,e){let s=e||(()=>{});try{let t=new fe(E),n=new wt(t);n.connect().then(()=>new Promise(n.importFile.bind(n,Object.assign({skipDbCheck:!0},E)))).then(()=>s()).catch(o=>s(o)).finally(()=>{new Promise(n.end.bind(n,{})).catch(console.log)})}catch(t){s(t)}}var zo={version:J_,SqlError:L,defaultOptions:z_,createConnection:en,createPool:tn,createPoolCluster:sn,importFile:rn};0&&(module.exports={SqlError,createConnection,createPool,createPoolCluster,defaultOptions,importFile,version});