/ OpenDB: Data Base open routine for JSN access method. */ /
| 1013 | /* OpenDB: Data Base open routine for JSN access method. */ |
| 1014 | /***********************************************************************/ |
| 1015 | bool TDBJSN::OpenDB(PGLOBAL g) |
| 1016 | { |
| 1017 | if (Use == USE_OPEN) { |
| 1018 | /*******************************************************************/ |
| 1019 | /* Table already open replace it at its beginning. */ |
| 1020 | /*******************************************************************/ |
| 1021 | Fpos= -1; |
| 1022 | NextSame = 0; |
| 1023 | SameRow = 0; |
| 1024 | } else { |
| 1025 | /*******************************************************************/ |
| 1026 | /* First opening. */ |
| 1027 | /*******************************************************************/ |
| 1028 | if (Mode == MODE_INSERT) |
| 1029 | switch (Jmode) { |
| 1030 | case MODE_OBJECT: Row = new(g) JOBJECT; break; |
| 1031 | case MODE_ARRAY: Row = new(g) JARRAY; break; |
| 1032 | case MODE_VALUE: Row = new(g) JVALUE; break; |
| 1033 | default: |
| 1034 | snprintf(g->Message, sizeof(g->Message), "Invalid Jmode %d", Jmode); |
| 1035 | return true; |
| 1036 | } // endswitch Jmode |
| 1037 | |
| 1038 | } // endif Use |
| 1039 | |
| 1040 | if (Pretty < 0) { |
| 1041 | /*******************************************************************/ |
| 1042 | /* Binary BJSON table. */ |
| 1043 | /*******************************************************************/ |
| 1044 | xtrc(1, "JSN OpenDB: tdbp=%p tdb=R%d use=%d mode=%d\n", |
| 1045 | this, Tdb_No, Use, Mode); |
| 1046 | |
| 1047 | if (Use == USE_OPEN) { |
| 1048 | /*******************************************************************/ |
| 1049 | /* Table already open, just replace it at its beginning. */ |
| 1050 | /*******************************************************************/ |
| 1051 | if (!To_Kindex) { |
| 1052 | Txfp->Rewind(); // see comment in Work.log |
| 1053 | } else // Table is to be accessed through a sorted index table |
| 1054 | To_Kindex->Reset(); |
| 1055 | |
| 1056 | return false; |
| 1057 | } // endif use |
| 1058 | |
| 1059 | /*********************************************************************/ |
| 1060 | /* Open according to logical input/output mode required. */ |
| 1061 | /* Use conventionnal input/output functions. */ |
| 1062 | /*********************************************************************/ |
| 1063 | if (Txfp->OpenTableFile(g)) |
| 1064 | return true; |
| 1065 | |
| 1066 | Use = USE_OPEN; // Do it now in case we are recursively called |
| 1067 | |
| 1068 | /*********************************************************************/ |
| 1069 | /* Lrecl is Ok. */ |
| 1070 | /*********************************************************************/ |
| 1071 | MODE mode = Mode; |
| 1072 |
no test coverage detected